neko941 commited on
Commit
0492776
1 Parent(s): 5e3b678

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +23 -12
app.py CHANGED
@@ -40,25 +40,36 @@ def check_file(file, suffix=''):
40
  st.title("Hololive Waifu Classification")
41
 
42
  image = st.text_input('Image URL', '')
43
- imgsz = st.text_input('Image Size', 1280)
 
 
 
 
 
 
 
44
  conf = st.slider(label='Confidence threshold', min_value=0.0, max_value=1.0, value=0.25, step=0.01)
45
  iou = st.slider(label='IoU threshold', min_value=0.0, max_value=1.0, value=0.45, step=0.01)
46
  multi_label = st.selectbox('Multiple labels per box', (False, True))
47
  agnostic = st.selectbox('Class-agnostic', (False, True))
48
  amp = st.selectbox('Automatic Mixed Precision inference', (False, True))
49
- max_det = st.text_input('Maximum number of detections per image', 1000)
50
 
51
  if st.button('Excute'):
52
- image = check_file(image)
53
- input_image = Image.open(image)
54
- model = torch.hub.load('ultralytics/yolov5', 'custom', path='best.pt')
55
- model.conf = float(conf)
56
- model.max_det = int(max_det)
57
- model.iou = float(iou)
58
- model.agnostic = agnostic
59
- model.multi_label = multi_label
60
- model.amp = amp
61
- results = model(input_image, size=int(imgsz))
 
 
 
 
62
  for img in results.render():
63
  st.image(img)
64
  st.write(results.pandas().xyxy[0])
 
40
  st.title("Hololive Waifu Classification")
41
 
42
  image = st.text_input('Image URL', '')
43
+ st.info(
44
+ 'Images for quick tesing:\n \n \n'
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
+ , icon="ℹ️")
49
+ pretrained = st.selectbox('Select pre-trained', ('best.pt', 'last.pt'))
50
+ imgsz = st.number_input(label='Image Size', min_value=None, max_value=None, value=1280, step=1)
51
  conf = st.slider(label='Confidence threshold', min_value=0.0, max_value=1.0, value=0.25, step=0.01)
52
  iou = st.slider(label='IoU threshold', min_value=0.0, max_value=1.0, value=0.45, step=0.01)
53
  multi_label = st.selectbox('Multiple labels per box', (False, True))
54
  agnostic = st.selectbox('Class-agnostic', (False, True))
55
  amp = st.selectbox('Automatic Mixed Precision inference', (False, True))
56
+ max_det = st.number_input(label='Maximum number of detections per image', min_value=None, max_value=None, value=1000, step=1)
57
 
58
  if st.button('Excute'):
59
+ with st.spinner('Loading the image...'):
60
+ image = check_file(image)
61
+ input_image = Image.open(image)
62
+ with st.spinner('Loading the model...'):
63
+ model = torch.hub.load('ultralytics/yolov5', 'custom', path=pretrained)
64
+ with st.spinner('Updating configuration...'):
65
+ model.conf = float(conf)
66
+ model.max_det = int(max_det)
67
+ model.iou = float(iou)
68
+ model.agnostic = agnostic
69
+ model.multi_label = multi_label
70
+ model.amp = amp
71
+ with st.spinner('Predicting...'):
72
+ results = model(input_image, size=int(imgsz))
73
  for img in results.render():
74
  st.image(img)
75
  st.write(results.pandas().xyxy[0])