Download from GH release instead of GDrive
Browse files
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
|
6 |
import gradio as gr
|
7 |
import numpy as np
|
8 |
import streamlit as st
|
9 |
|
10 |
-
DMINITY_MODEL_URL = "https://
|
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 |
-
|
|
|
|
|
|
|
|
|
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)
|