Dolpheyn commited on
Commit
af0a65d
·
1 Parent(s): ec6037b

Download from GH release instead of GDrive

Browse files
Files changed (1) hide show
  1. app.py +7 -3
app.py CHANGED
@@ -2,19 +2,23 @@ from PIL import Image
2
  from model import yolox
3
  from os import listdir
4
  import os.path
5
- import gdown
6
  import gradio as gr
7
  import numpy as np
8
  import streamlit as st
9
 
10
- DMINITY_MODEL_URL = "https://drive.google.com/uc?id=1gb3Pq5UM41IvkqQqe4vDExSBza9dmwr0"
11
  MODEL_PATH = "dminity.onnx"
12
 
13
  @st.cache(allow_output_mutation=True, show_spinner=True)
14
  def get_model():
15
  # Download model from Google Drive if it does not exist
16
  if not os.path.isfile(MODEL_PATH):
17
- gdown.download(DMINITY_MODEL_URL, MODEL_PATH)
 
 
 
 
18
 
19
  # Load model with OpenCV
20
  model = yolox(MODEL_PATH, p6=False, confThreshold=0.3)
 
2
  from model import yolox
3
  from os import listdir
4
  import os.path
5
+ import requests
6
  import gradio as gr
7
  import numpy as np
8
  import streamlit as st
9
 
10
+ DMINITY_MODEL_URL = "https://github.com/Dolpheyn/dminity/releases/download/v-1.0.0/dminity.onnx"
11
  MODEL_PATH = "dminity.onnx"
12
 
13
  @st.cache(allow_output_mutation=True, show_spinner=True)
14
  def get_model():
15
  # Download model from Google Drive if it does not exist
16
  if not os.path.isfile(MODEL_PATH):
17
+ print("Downloading dminity model weight from {}...".format(DMINITY_MODEL_URL))
18
+ r = requests.get(DMINITY_MODEL_URL, allow_redirects=True)
19
+ print("Writing to {}".format(MODEL_PATH))
20
+ open(MODEL_PATH, 'wb').write(r.content)
21
+ print("Done!")
22
 
23
  # Load model with OpenCV
24
  model = yolox(MODEL_PATH, p6=False, confThreshold=0.3)