neko941 commited on
Commit
b2bee1d
1 Parent(s): a9dc373

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +8 -8
app.py CHANGED
@@ -36,10 +36,10 @@ def check_file(file, suffix=''):
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
 
44
  st.title("Hololive Waifu Classification")
45
 
@@ -64,18 +64,18 @@ agnostic = st.selectbox('Class-agnostic', (False, True))
64
  amp = st.selectbox('Automatic Mixed Precision inference', (False, True))
65
  max_det = st.number_input(label='Maximum number of detections per image', min_value=None, max_value=None, value=1000, step=1)
66
  clicked = st.button('Excute')
67
- with st.spinner('Loading the model...'):
68
- model = read_pretrain(default_pretrained)
69
 
70
  if clicked:
71
  with st.spinner('Loading the image...'):
72
  image_path = check_file(image)
73
  input_image = Image.open(image_path)
74
- if default_pretrained != pretrained:
75
- with st.spinner('Loading the model...'):
76
  # model = torch.hub.load('ultralytics/yolov5', 'custom', path=os.path.join('pretrained', pretrained))
77
  # model = torch.hub.load('ultralytics/yolov5', 'custom', path=pretrained)
78
- model = read_pretrain(pretrained)
79
  with st.spinner('Updating configuration...'):
80
  model.conf = float(conf)
81
  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
 
44
  st.title("Hololive Waifu Classification")
45
 
 
64
  amp = st.selectbox('Automatic Mixed Precision inference', (False, True))
65
  max_det = st.number_input(label='Maximum number of detections per image', min_value=None, max_value=None, value=1000, step=1)
66
  clicked = st.button('Excute')
67
+ # with st.spinner('Loading the model...'):
68
+ # model = read_pretrain(default_pretrained)
69
 
70
  if clicked:
71
  with st.spinner('Loading the image...'):
72
  image_path = check_file(image)
73
  input_image = Image.open(image_path)
74
+ # if default_pretrained != pretrained:
75
+ with st.spinner('Loading the model...'):
76
  # model = torch.hub.load('ultralytics/yolov5', 'custom', path=os.path.join('pretrained', pretrained))
77
  # model = torch.hub.load('ultralytics/yolov5', 'custom', path=pretrained)
78
+ model = read_pretrain(pretrained)
79
  with st.spinner('Updating configuration...'):
80
  model.conf = float(conf)
81
  model.max_det = int(max_det)