sovitrath commited on
Commit
b137505
β€’
1 Parent(s): 0c6b7d0

Images download from URL

Browse files
app.py CHANGED
@@ -1,11 +1,30 @@
1
  import gradio as gr
2
  from gradio.outputs import Label
3
  import cv2
 
 
4
 
5
  from ultralytics import YOLO
6
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
7
  model = YOLO('best.pt')
8
- path = [['pothole_example.jpg'], ['pothole_screenshot.png']]
9
 
10
  def show_preds(image_path):
11
  image = cv2.imread(image_path)
@@ -30,8 +49,8 @@ gr_interface = gr.Interface(
30
  outputs=gr.outputs.Image(type="numpy", label="Output Image"),
31
  title="Pothole detector",
32
  examples=path,
33
- cache_examples=True,
34
- live=True,
35
  )
36
 
37
  gr_interface.launch(debug=True, enable_queue=True)
 
1
  import gradio as gr
2
  from gradio.outputs import Label
3
  import cv2
4
+ import requests
5
+ import os
6
 
7
  from ultralytics import YOLO
8
 
9
+ file_urls = [
10
+ 'https://www.dropbox.com/s/b5g97xo901zb3ds/pothole_example.jpg?dl=1',
11
+ 'https://www.dropbox.com/s/86uxlxxlm1iaexa/pothole_screenshot.png?dl=1'
12
+ ]
13
+
14
+ def download_file(url, save_name):
15
+ url = url
16
+ if not os.path.exists(save_name):
17
+ file = requests.get(url)
18
+ open(save_name, 'wb').write(file.content)
19
+
20
+ for i, url in enumerate(file_urls):
21
+ download_file(
22
+ file_urls[i],
23
+ f"image_{i}.jpg"
24
+ )
25
+
26
  model = YOLO('best.pt')
27
+ path = [['image_0.jpg'], ['image_1.jpg']]
28
 
29
  def show_preds(image_path):
30
  image = cv2.imread(image_path)
 
49
  outputs=gr.outputs.Image(type="numpy", label="Output Image"),
50
  title="Pothole detector",
51
  examples=path,
52
+ # cache_examples=True,
53
+ # live=True,
54
  )
55
 
56
  gr_interface.launch(debug=True, enable_queue=True)
gradio_cached_examples/12/Output Image/tmp2gxdj84j.png ADDED
gradio_cached_examples/12/Output Image/tmpz66236qf.png ADDED
gradio_cached_examples/12/log.csv ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ Output Image,flag,username,timestamp
2
+ /media/sovit/hdd1tbinternal/my_data/Data_Science/Big_Vision/pothole_project/huggingface_spaces/yolov8n/pothole_yolov8_nano/gradio_cached_examples/12/Output Image/tmp2gxdj84j.png,,,2023-01-13 09:31:17.531032
3
+ /media/sovit/hdd1tbinternal/my_data/Data_Science/Big_Vision/pothole_project/huggingface_spaces/yolov8n/pothole_yolov8_nano/gradio_cached_examples/12/Output Image/tmpz66236qf.png,,,2023-01-13 09:31:18.272697
pothole_example.jpg β†’ image_0.jpg RENAMED
File without changes
pothole_screenshot.png β†’ image_1.jpg RENAMED
File without changes