Thien Tran commited on
Commit
2eaf78d
1 Parent(s): bd97504

fix detectron2 installation

Browse files
Files changed (3) hide show
  1. README.md +0 -1
  2. app.py +7 -0
  3. requirements.txt +2 -4
README.md CHANGED
@@ -6,7 +6,6 @@ colorTo: green
6
  sdk: gradio
7
  app_file: app.py
8
  pinned: false
9
- python_version: "3.9"
10
  ---
11
 
12
  # Configuration
 
6
  sdk: gradio
7
  app_file: app.py
8
  pinned: false
 
9
  ---
10
 
11
  # Configuration
app.py CHANGED
@@ -1,3 +1,10 @@
 
 
 
 
 
 
 
1
  import gradio as gr
2
  import numpy as np
3
  from transformers import LayoutLMv2Processor, LayoutLMv2ForTokenClassification
 
1
+ import os
2
+
3
+ # build detectron2 from source
4
+ # we can't build detectron2 in requirements.txt because it needs PyTorch installed first,
5
+ # but requirements.txt will try to build wheels before installing any packages.
6
+ os.system("pip install git+https://github.com/facebookresearch/detectron2.git")
7
+
8
  import gradio as gr
9
  import numpy as np
10
  from transformers import LayoutLMv2Processor, LayoutLMv2ForTokenClassification
requirements.txt CHANGED
@@ -1,10 +1,8 @@
1
  --index-url https://download.pytorch.org/whl/cpu
2
- --extra-index-url https://dl.fbaipublicfiles.com/detectron2/wheels/cpu/torch1.10/index.html
3
  --extra-index-url https://pypi.org/simple
4
  Pillow
5
  numpy
6
- torch==1.10.1+cpu
7
- torchvision==0.11.2+cpu
8
  transformers
9
- detectron2
10
  pytesseract
 
1
  --index-url https://download.pytorch.org/whl/cpu
 
2
  --extra-index-url https://pypi.org/simple
3
  Pillow
4
  numpy
5
+ torch
6
+ torchvision
7
  transformers
 
8
  pytesseract