pirahansiah commited on
Commit
9fcf801
β€’
1 Parent(s): b2923e7

computer vision 1

Browse files
Files changed (4) hide show
  1. README.md +4 -4
  2. app.py +91 -0
  3. gitignore +8 -0
  4. requirements.txt +47 -0
README.md CHANGED
@@ -1,8 +1,8 @@
1
  ---
2
- title: ComputerVision
3
- emoji: πŸš€
4
- colorFrom: purple
5
- colorTo: pink
6
  sdk: gradio
7
  sdk_version: 3.39.0
8
  app_file: app.py
 
1
  ---
2
+ title: Farshid
3
+ emoji: πŸƒ
4
+ colorFrom: pink
5
+ colorTo: yellow
6
  sdk: gradio
7
  sdk_version: 3.39.0
8
  app_file: app.py
app.py ADDED
@@ -0,0 +1,91 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+ import cv2
3
+ import requests
4
+ import os
5
+
6
+ from ultralytics import YOLO
7
+
8
+ file_urls = [
9
+ 'https://lh3.googleusercontent.com/a2iyhpYl4Jgzc0r7MYgXQI1BGwkutp3rKuauNpkEbD3Z_HP-gf29M-wugKebKJQdl8ILtKWN-vOZAS9r1qMsI88=w16383'
10
+ ]
11
+
12
+ def download_file(url, save_name):
13
+ url = url
14
+ if not os.path.exists(save_name):
15
+ file = requests.get(url)
16
+ open(save_name, 'wb').write(file.content)
17
+
18
+ for i, url in enumerate(file_urls):
19
+ if 'mp4' in file_urls[i]:
20
+ download_file(
21
+ file_urls[i],
22
+ f"video.mp4"
23
+ )
24
+ else:
25
+ download_file(
26
+ file_urls[i],
27
+ f"image_{i}.jpg"
28
+ )
29
+
30
+
31
+ path = [['image_0.jpg']]
32
+
33
+
34
+ def show_preds_image(image_path):
35
+ image = cv2.imread(image_path,0)
36
+ return image #cv2.cvtColor(image, cv2.COLOR_BGR2RGB)
37
+
38
+ inputs_image = [
39
+ gr.components.Image(type="filepath", label="Input Image"),
40
+ ]
41
+ outputs_image = [
42
+ gr.components.Image(type="numpy", label="Output Image"),
43
+ ]
44
+ interface_image = gr.Interface(
45
+ fn=show_preds_image,
46
+ inputs=inputs_image,
47
+ outputs=outputs_image,
48
+ title="Computer Vision and Deep Learning by Farshid PirahanSiah",
49
+ examples=path,
50
+ cache_examples=False,
51
+ )
52
+
53
+ # def show_preds_video(video_path):
54
+ # cap = cv2.VideoCapture(video_path)
55
+ # while(cap.isOpened()):
56
+ # ret, frame = cap.read()
57
+ # if ret:
58
+ # frame_copy = frame.copy()
59
+ # outputs = model.predict(source=frame)
60
+ # results = outputs[0].cpu().numpy()
61
+ # for i, det in enumerate(results.boxes.xyxy):
62
+ # cv2.rectangle(
63
+ # frame_copy,
64
+ # (int(det[0]), int(det[1])),
65
+ # (int(det[2]), int(det[3])),
66
+ # color=(0, 0, 255),
67
+ # thickness=2,
68
+ # lineType=cv2.LINE_AA
69
+ # )
70
+ # yield cv2.cvtColor(frame_copy, cv2.COLOR_BGR2RGB)
71
+
72
+ # inputs_video = [
73
+ # gr.components.Video(type="filepath", label="Input Video"),
74
+
75
+ # ]
76
+ # outputs_video = [
77
+ # gr.components.Image(type="numpy", label="Output Image"),
78
+ # ]
79
+ # interface_video = gr.Interface(
80
+ # fn=show_preds_video,
81
+ # inputs=inputs_video,
82
+ # outputs=outputs_video,
83
+ # title="Pothole detector",
84
+ # examples=video_path,
85
+ # cache_examples=False,
86
+ # )
87
+
88
+ # gr.TabbedInterface(
89
+ # [interface_image, interface_video],
90
+ # tab_names=['Image inference', 'Video inference']
91
+ # ).queue().launch()
gitignore ADDED
@@ -0,0 +1,8 @@
 
 
 
 
 
 
 
 
 
1
+ flagged/
2
+ *.pt
3
+ *.png
4
+ *.jpg
5
+ *.mp4
6
+ *.mkv
7
+ gradio_cached_examples/
8
+ .DS_Store
requirements.txt ADDED
@@ -0,0 +1,47 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Ultralytics requirements
2
+ # Usage: pip install -r requirements.txt
3
+
4
+ # Base ----------------------------------------
5
+ hydra-core>=1.2.0
6
+ matplotlib>=3.2.2
7
+ numpy>=1.18.5
8
+ opencv-python>=4.1.1
9
+ Pillow>=7.1.2
10
+ PyYAML>=5.3.1
11
+ requests>=2.23.0
12
+ scipy>=1.4.1
13
+ torch>=1.7.0
14
+ torchvision>=0.8.1
15
+ tqdm>=4.64.0
16
+ ultralytics
17
+
18
+ # Logging -------------------------------------
19
+ tensorboard>=2.4.1
20
+ # clearml
21
+ # comet
22
+
23
+ # Plotting ------------------------------------
24
+ pandas>=1.1.4
25
+ seaborn>=0.11.0
26
+
27
+ # Export --------------------------------------
28
+ # coremltools>=6.0 # CoreML export
29
+ # onnx>=1.12.0 # ONNX export
30
+ # onnx-simplifier>=0.4.1 # ONNX simplifier
31
+ # nvidia-pyindex # TensorRT export
32
+ # nvidia-tensorrt # TensorRT export
33
+ # scikit-learn==0.19.2 # CoreML quantization
34
+ # tensorflow>=2.4.1 # TF exports (-cpu, -aarch64, -macos)
35
+ # tensorflowjs>=3.9.0 # TF.js export
36
+ # openvino-dev # OpenVINO export
37
+
38
+ # Extras --------------------------------------
39
+ ipython # interactive notebook
40
+ psutil # system utilization
41
+ thop>=0.1.1 # FLOPs computation
42
+ # albumentations>=1.0.3
43
+ # pycocotools>=2.0.6 # COCO mAP
44
+ # roboflow
45
+
46
+ # HUB -----------------------------------------
47
+ GitPython>=3.1.24