Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -36,7 +36,13 @@ def check_file(file, suffix=''):
|
|
36 |
).st_size > 0, f'File download failed: {url}' # check
|
37 |
return file
|
38 |
|
39 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
40 |
st.title("Hololive Waifu Classification")
|
41 |
|
42 |
image = st.text_input('Image URL', '')
|
@@ -51,7 +57,7 @@ st.info(
|
|
51 |
' - https://megapx-assets.dcard.tw/images/65993ab1-fe08-43be-87cd-2ecd201cacbd/1280.jpeg'
|
52 |
'\n \n \n'
|
53 |
' - https://img.esportsku.com/wp-content/uploads//2021/07/hololive-en.png')
|
54 |
-
pretrained = st.selectbox('Select pre-trained', ('2022.11.
|
55 |
imgsz = st.number_input(label='Image Size', min_value=None, max_value=None, value=1280, step=1)
|
56 |
conf = st.slider(label='Confidence threshold', min_value=0.0, max_value=1.0, value=0.25, step=0.01)
|
57 |
iou = st.slider(label='IoU threshold', min_value=0.0, max_value=1.0, value=0.45, step=0.01)
|
@@ -64,9 +70,10 @@ if st.button('Excute'):
|
|
64 |
with st.spinner('Loading the image...'):
|
65 |
image_path = check_file(image)
|
66 |
input_image = Image.open(image_path)
|
67 |
-
|
68 |
-
|
69 |
-
|
|
|
70 |
with st.spinner('Updating configuration...'):
|
71 |
model.conf = float(conf)
|
72 |
model.max_det = int(max_det)
|
|
|
36 |
).st_size > 0, f'File download failed: {url}' # check
|
37 |
return file
|
38 |
|
39 |
+
def read_pretrain(path):
|
40 |
+
return torch.hub.load('ultralytics/yolov5', 'custom', path=path
|
41 |
+
|
42 |
+
default_pretrained = '2022.11.04-YOLOv5x6_1280-Hololive_Waifu_Classification.pt'
|
43 |
+
with st.spinner('Loading the model...'):
|
44 |
+
read_pretrain(default_pretrained)
|
45 |
+
|
46 |
st.title("Hololive Waifu Classification")
|
47 |
|
48 |
image = st.text_input('Image URL', '')
|
|
|
57 |
' - https://megapx-assets.dcard.tw/images/65993ab1-fe08-43be-87cd-2ecd201cacbd/1280.jpeg'
|
58 |
'\n \n \n'
|
59 |
' - https://img.esportsku.com/wp-content/uploads//2021/07/hololive-en.png')
|
60 |
+
pretrained = st.selectbox('Select pre-trained', ('2022.11.04-YOLOv5x6_1280-Hololive_Waifu_Classification.pt', '2022.11.01-YOLOv5x6_1280-Hololive_Waifu_Classification.pt'))
|
61 |
imgsz = st.number_input(label='Image Size', min_value=None, max_value=None, value=1280, step=1)
|
62 |
conf = st.slider(label='Confidence threshold', min_value=0.0, max_value=1.0, value=0.25, step=0.01)
|
63 |
iou = st.slider(label='IoU threshold', min_value=0.0, max_value=1.0, value=0.45, step=0.01)
|
|
|
70 |
with st.spinner('Loading the image...'):
|
71 |
image_path = check_file(image)
|
72 |
input_image = Image.open(image_path)
|
73 |
+
if default_pretrained != pretrained:
|
74 |
+
with st.spinner('Loading the model...'):
|
75 |
+
# model = torch.hub.load('ultralytics/yolov5', 'custom', path=os.path.join('pretrained', pretrained))
|
76 |
+
model = torch.hub.load('ultralytics/yolov5', 'custom', path=pretrained)
|
77 |
with st.spinner('Updating configuration...'):
|
78 |
model.conf = float(conf)
|
79 |
model.max_det = int(max_det)
|