Spaces:
Runtime error
Runtime error
Upload app.py
Browse files
app.py
CHANGED
@@ -45,7 +45,7 @@ st.info(
|
|
45 |
' - https://i.imgur.com/tFZwWYw.jpg'
|
46 |
'\n \n \n'
|
47 |
' - https://static.wikia.nocookie.net/omniversal-battlefield/images/b/bd/Council.jpg')
|
48 |
-
pretrained = st.selectbox('Select pre-trained', ('
|
49 |
imgsz = st.number_input(label='Image Size', min_value=None, max_value=None, value=1280, step=1)
|
50 |
conf = st.slider(label='Confidence threshold', min_value=0.0, max_value=1.0, value=0.25, step=0.01)
|
51 |
iou = st.slider(label='IoU threshold', min_value=0.0, max_value=1.0, value=0.45, step=0.01)
|
@@ -56,10 +56,10 @@ max_det = st.number_input(label='Maximum number of detections per image', min_v
|
|
56 |
|
57 |
if st.button('Excute'):
|
58 |
with st.spinner('Loading the image...'):
|
59 |
-
|
60 |
-
input_image = Image.open(
|
61 |
with st.spinner('Loading the model...'):
|
62 |
-
model = torch.hub.load('ultralytics/yolov5', 'custom', path=pretrained)
|
63 |
with st.spinner('Updating configuration...'):
|
64 |
model.conf = float(conf)
|
65 |
model.max_det = int(max_det)
|
@@ -71,4 +71,5 @@ if st.button('Excute'):
|
|
71 |
results = model(input_image, size=int(imgsz))
|
72 |
for img in results.render():
|
73 |
st.image(img)
|
74 |
-
st.write(results.pandas().xyxy[0])
|
|
|
|
45 |
' - https://i.imgur.com/tFZwWYw.jpg'
|
46 |
'\n \n \n'
|
47 |
' - https://static.wikia.nocookie.net/omniversal-battlefield/images/b/bd/Council.jpg')
|
48 |
+
pretrained = st.selectbox('Select pre-trained', ('2022.11.01-YOLOv5x6_1280-Hololive_Waifu_Classification.pt', 'last.pt'))
|
49 |
imgsz = st.number_input(label='Image Size', min_value=None, max_value=None, value=1280, step=1)
|
50 |
conf = st.slider(label='Confidence threshold', min_value=0.0, max_value=1.0, value=0.25, step=0.01)
|
51 |
iou = st.slider(label='IoU threshold', min_value=0.0, max_value=1.0, value=0.45, step=0.01)
|
|
|
56 |
|
57 |
if st.button('Excute'):
|
58 |
with st.spinner('Loading the image...'):
|
59 |
+
image_path = check_file(image)
|
60 |
+
input_image = Image.open(image_path)
|
61 |
with st.spinner('Loading the model...'):
|
62 |
+
model = torch.hub.load('ultralytics/yolov5', 'custom', path=os.path.join('pretrained', pretrained))
|
63 |
with st.spinner('Updating configuration...'):
|
64 |
model.conf = float(conf)
|
65 |
model.max_det = int(max_det)
|
|
|
71 |
results = model(input_image, size=int(imgsz))
|
72 |
for img in results.render():
|
73 |
st.image(img)
|
74 |
+
st.write(results.pandas().xyxy[0])
|
75 |
+
os.remove(image_path)
|