Spaces:
Sleeping
Sleeping
Commit
•
2c654db
1
Parent(s):
4e700ac
Added yolov7 model (#4)
Browse files- Added yolov7 model (55c9080b7a0b76efa679504df1cf5a93fa291cbc)
Co-authored-by: Kadir Nar <kadirnar@users.noreply.huggingface.co>
- app.py +9 -2
- requirements.txt +2 -1
app.py
CHANGED
@@ -7,9 +7,9 @@ import os
|
|
7 |
|
8 |
os.system('pip install git+https://github.com/fcakyon/ultralyticsplus.git')
|
9 |
|
10 |
-
model_id_list = ['deprem-ml/Binafarktespit-yolo5x-v1-xview', 'SerdarHelli/deprem_satellite_labeled_yolov8']
|
11 |
current_device = "cuda" if torch.cuda.is_available() else "cpu"
|
12 |
-
model_types = ["YOLOv5", "YOLOv5 + SAHI", "YOLOv8"]
|
13 |
|
14 |
def sahi_yolov5_inference(
|
15 |
image,
|
@@ -92,6 +92,13 @@ def sahi_yolov5_inference(
|
|
92 |
result = model.predict(image, imgsz=image_size)[0]
|
93 |
render = render_result(model=model, image=image, result=result, rect_th=rect_th, text_th=text_th)
|
94 |
return render
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
95 |
|
96 |
inputs = [
|
97 |
gr.Image(type="pil", label="Original Image"),
|
|
|
7 |
|
8 |
os.system('pip install git+https://github.com/fcakyon/ultralyticsplus.git')
|
9 |
|
10 |
+
model_id_list = ['deprem-ml/Binafarktespit-yolo5x-v1-xview', 'SerdarHelli/deprem_satellite_labeled_yolov8', 'kadirnar/yolov7-v0.1']
|
11 |
current_device = "cuda" if torch.cuda.is_available() else "cpu"
|
12 |
+
model_types = ["YOLOv5", "YOLOv5 + SAHI", "YOLOv8", "YOLOv7"]
|
13 |
|
14 |
def sahi_yolov5_inference(
|
15 |
image,
|
|
|
92 |
result = model.predict(image, imgsz=image_size)[0]
|
93 |
render = render_result(model=model, image=image, result=result, rect_th=rect_th, text_th=text_th)
|
94 |
return render
|
95 |
+
|
96 |
+
elif model_type == "YOLOv7":
|
97 |
+
import yolov7
|
98 |
+
|
99 |
+
model = yolov7.load(model_id, device="cuda:0", hf_model=True, trace=False)
|
100 |
+
results = model([image], size=image_size)
|
101 |
+
return results.render()[0]
|
102 |
|
103 |
inputs = [
|
104 |
gr.Image(type="pil", label="Original Image"),
|
requirements.txt
CHANGED
@@ -1,4 +1,5 @@
|
|
1 |
torch==1.10.2
|
2 |
torchvision==0.11.3
|
3 |
yolov5==7.0.8
|
4 |
-
sahi==0.11.11
|
|
|
|
1 |
torch==1.10.2
|
2 |
torchvision==0.11.3
|
3 |
yolov5==7.0.8
|
4 |
+
sahi==0.11.11
|
5 |
+
yolov7detect==1.0.1
|