Skip to content

Commit

Permalink
Automate doctr demo update
Browse files Browse the repository at this point in the history
  • Loading branch information
felixdittrich92 committed Oct 7, 2024
1 parent 90c3fff commit 2d16bbf
Show file tree
Hide file tree
Showing 5 changed files with 101 additions and 5 deletions.
54 changes: 51 additions & 3 deletions .github/workflows/demo.yml
Original file line number Diff line number Diff line change
@@ -1,10 +1,23 @@
name: demo

on:
push:
branches: main
# Run 'test-demo' on every pull request to the main branch
pull_request:
branches: main
branches: [main]

# Run 'test-demo' on every push to the main branch or both jobs when a new version tag is pushed
push:
branches:
- main
tags:
- 'v*'

# Run 'sync-to-hub' on a scheduled cron job
schedule:
- cron: '0 2 10 * *' # At 02:00 on day-of-month 10 (every month)

# Allow manual triggering of the workflow
workflow_dispatch:

jobs:
test-demo:
Expand Down Expand Up @@ -69,3 +82,38 @@ jobs:
screen -dm streamlit run demo/app.py
sleep 10
curl http://localhost:8501/docs
# This job only runs when a new version tag is pushed or during the cron job or when manually triggered
sync-to-hub:
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/v') || github.event_name == 'schedule' || github.event_name == 'workflow_dispatch'
needs: test-demo
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest]
python: ["3.9"]
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python }}
architecture: x64
- name: Install huggingface_hub
run: pip install huggingface-hub
- name: Upload folder to Hugging Face
# Only keep the requirements.txt file for the demo (PyTorch)
run: |
mv demo/pt-requirements.txt demo/requirements.txt
rm demo/tf-requirements.txt
python -c "
from huggingface_hub import HfApi
api = HfApi(token='${{ secrets.HF_TOKEN }}')
repo_id = 'mindee/doctr'
api.upload_folder(repo_id=repo_id, repo_type='space', folder_path='demo/')
api.restart_space(repo_id=repo_id, factory_reboot=True)
"
47 changes: 47 additions & 0 deletions demo/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
---
title: docTR
emoji: 📑
colorFrom: purple
colorTo: pink
sdk: streamlit
sdk_version: 4.44.1
app_file: app.py
pinned: false
license: apache-2.0
---

## Configuration

`title`: _string_
Display title for the Space

`emoji`: _string_
Space emoji (emoji-only character allowed)

`colorFrom`: _string_
Color for Thumbnail gradient (red, yellow, green, blue, indigo, purple, pink, gray)

`colorTo`: _string_
Color for Thumbnail gradient (red, yellow, green, blue, indigo, purple, pink, gray)

`sdk`: _string_
Can be either `gradio` or `streamlit`

`sdk_version` : _string_
Only applicable for `streamlit` SDK.
See [doc](https://hf.co/docs/hub/spaces) for more info on supported versions.

`app_file`: _string_
Path to your main application file (which contains either `gradio` or `streamlit` Python code).
Path is relative to the root of the repository.

`pinned`: _boolean_
Whether the Space stays on top of your list.

## Run the demo locally

```bash
cd demo
pip install -r pt-requirements.txt
streamlit run app.py
```
1 change: 1 addition & 0 deletions demo/packages.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
python3-opencv
2 changes: 1 addition & 1 deletion demo/pt-requirements.txt
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
-e git+https://github.com/mindee/doctr.git#egg=python-doctr[torch]
streamlit>=1.0.0
streamlit>=4.0.0
2 changes: 1 addition & 1 deletion demo/tf-requirements.txt
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
-e git+https://github.com/mindee/doctr.git#egg=python-doctr[tf]
streamlit>=1.0.0
streamlit>=4.0.0

0 comments on commit 2d16bbf

Please sign in to comment.