pirahansiah commited on
Commit
b7e2377
·
1 Parent(s): c4f15fb

computer vision 1

Browse files
Files changed (2) hide show
  1. .DS_Store +0 -0
  2. app.py +6 -53
.DS_Store ADDED
Binary file (6.15 kB). View file
 
app.py CHANGED
@@ -6,8 +6,7 @@ import os
6
  from ultralytics import YOLO
7
 
8
  file_urls = [
9
- 'https://github.com/pirahansiah/farshid/blob/eda35793771c298696dba7eadc0fbc74931ef8fd/OpenCV_book/5/AIoT.png',
10
- 'https://www.dropbox.com/s/7sjfwncffg8xej2/video_7.mp4?dl=1'
11
  ]
12
 
13
  def download_file(url, save_name):
@@ -17,16 +16,10 @@ def download_file(url, save_name):
17
  open(save_name, 'wb').write(file.content)
18
 
19
  for i, url in enumerate(file_urls):
20
- if 'mp4' in file_urls[i]:
21
- download_file(
22
- file_urls[i],
23
- f"video.mp4"
24
- )
25
- else:
26
- download_file(
27
- file_urls[i],
28
- f"image_{i}.png"
29
- )
30
 
31
 
32
  path = [['image_0.png']]
@@ -54,44 +47,4 @@ interface_image = gr.Interface(
54
  gr.TabbedInterface(
55
  [interface_image],
56
  tab_names=['Image Processing']
57
- ).queue().launch()
58
-
59
- # def show_preds_video(video_path):
60
- # cap = cv2.VideoCapture(video_path)
61
- # while(cap.isOpened()):
62
- # ret, frame = cap.read()
63
- # if ret:
64
- # frame_copy = frame.copy()
65
- # outputs = model.predict(source=frame)
66
- # results = outputs[0].cpu().numpy()
67
- # for i, det in enumerate(results.boxes.xyxy):
68
- # cv2.rectangle(
69
- # frame_copy,
70
- # (int(det[0]), int(det[1])),
71
- # (int(det[2]), int(det[3])),
72
- # color=(0, 0, 255),
73
- # thickness=2,
74
- # lineType=cv2.LINE_AA
75
- # )
76
- # yield cv2.cvtColor(frame_copy, cv2.COLOR_BGR2RGB)
77
-
78
- # inputs_video = [
79
- # gr.components.Video(type="filepath", label="Input Video"),
80
-
81
- # ]
82
- # outputs_video = [
83
- # gr.components.Image(type="numpy", label="Output Image"),
84
- # ]
85
- # interface_video = gr.Interface(
86
- # fn=show_preds_video,
87
- # inputs=inputs_video,
88
- # outputs=outputs_video,
89
- # title="Video Processing ",
90
- # examples=video_path,
91
- # cache_examples=False,
92
- # )
93
-
94
- # gr.TabbedInterface(
95
- # [interface_image, interface_video],
96
- # tab_names=['Image inference', 'Video inference']
97
- # ).queue().launch()
 
6
  from ultralytics import YOLO
7
 
8
  file_urls = [
9
+ 'https://onedrive.live.com/embed?resid=CEE9ECC964C491B8%2123411&authkey=%21AFboK-sTQYxPuQo'
 
10
  ]
11
 
12
  def download_file(url, save_name):
 
16
  open(save_name, 'wb').write(file.content)
17
 
18
  for i, url in enumerate(file_urls):
19
+ download_file(
20
+ file_urls[i],
21
+ f"image_{i}.png"
22
+ )
 
 
 
 
 
 
23
 
24
 
25
  path = [['image_0.png']]
 
47
  gr.TabbedInterface(
48
  [interface_image],
49
  tab_names=['Image Processing']
50
+ ).queue().launch(share=True)