Ashegh-Sad-Warrior
commited on
Commit
•
ad41e33
1
Parent(s):
7062f02
Update app.py
Browse files
app.py
CHANGED
@@ -66,11 +66,11 @@ def detect_and_draw_image(input_image):
|
|
66 |
print("Model prediction completed.")
|
67 |
|
68 |
# دسترسی به نتایج OBB
|
69 |
-
if hasattr(results[0], '
|
70 |
-
obb_results = results[0].
|
71 |
print("Accessed obb_results.")
|
72 |
else:
|
73 |
-
print("No '
|
74 |
obb_results = None
|
75 |
|
76 |
# بررسی وجود جعبههای شناسایی شده
|
@@ -90,14 +90,10 @@ def detect_and_draw_image(input_image):
|
|
90 |
print("Image loaded with OpenCV.")
|
91 |
|
92 |
counts = {}
|
93 |
-
for
|
94 |
-
|
95 |
-
|
96 |
-
|
97 |
-
else:
|
98 |
-
x_center, y_center, width, height, rotation = box.tolist()[:5]
|
99 |
-
class_id = int(box.cls.tolist()[0]) if hasattr(box, 'cls') else 0
|
100 |
-
confidence = float(box.conf.tolist()[0]) if hasattr(box, 'conf') else 0.0
|
101 |
|
102 |
# رسم جعبه چرخان با استفاده از OpenCV
|
103 |
rect = ((x_center, y_center), (width, height), rotation * 180.0 / np.pi) # تبدیل رادیان به درجه
|
@@ -171,22 +167,18 @@ def detect_and_draw_video(video_path):
|
|
171 |
print(f"Model prediction completed for frame {frame_count}.")
|
172 |
|
173 |
# دسترسی به نتایج OBB
|
174 |
-
if hasattr(results[0], '
|
175 |
-
obb_results = results[0].
|
176 |
print("Accessed obb_results for frame.")
|
177 |
else:
|
178 |
-
print("No '
|
179 |
obb_results = None
|
180 |
|
181 |
if obb_results is not None and len(obb_results.data) > 0:
|
182 |
-
for
|
183 |
-
|
184 |
-
|
185 |
-
|
186 |
-
else:
|
187 |
-
x_center, y_center, width, height, rotation = box.tolist()[:5]
|
188 |
-
class_id = int(box.cls.tolist()[0]) if hasattr(box, 'cls') else 0
|
189 |
-
confidence = float(box.conf.tolist()[0]) if hasattr(box, 'conf') else 0.0
|
190 |
|
191 |
# رسم جعبه چرخان با استفاده از OpenCV
|
192 |
rect = ((x_center, y_center), (width, height), rotation * 180.0 / np.pi) # تبدیل رادیان به درجه
|
|
|
66 |
print("Model prediction completed.")
|
67 |
|
68 |
# دسترسی به نتایج OBB
|
69 |
+
if hasattr(results[0], 'obb') and results[0].obb is not None:
|
70 |
+
obb_results = results[0].obb # استفاده از obb برای مدل OBB
|
71 |
print("Accessed obb_results.")
|
72 |
else:
|
73 |
+
print("No 'obb' attribute found in results[0].")
|
74 |
obb_results = None
|
75 |
|
76 |
# بررسی وجود جعبههای شناسایی شده
|
|
|
90 |
print("Image loaded with OpenCV.")
|
91 |
|
92 |
counts = {}
|
93 |
+
for obb, conf, cls in zip(obb_results.data.cpu().numpy(), obb_results.conf.cpu().numpy(), obb_results.cls.cpu().numpy()):
|
94 |
+
x_center, y_center, width, height, rotation = obb[:5]
|
95 |
+
class_id = int(cls)
|
96 |
+
confidence = float(conf)
|
|
|
|
|
|
|
|
|
97 |
|
98 |
# رسم جعبه چرخان با استفاده از OpenCV
|
99 |
rect = ((x_center, y_center), (width, height), rotation * 180.0 / np.pi) # تبدیل رادیان به درجه
|
|
|
167 |
print(f"Model prediction completed for frame {frame_count}.")
|
168 |
|
169 |
# دسترسی به نتایج OBB
|
170 |
+
if hasattr(results[0], 'obb') and results[0].obb is not None:
|
171 |
+
obb_results = results[0].obb # استفاده از obb برای مدل OBB
|
172 |
print("Accessed obb_results for frame.")
|
173 |
else:
|
174 |
+
print("No 'obb' attribute found in results[0] for frame.")
|
175 |
obb_results = None
|
176 |
|
177 |
if obb_results is not None and len(obb_results.data) > 0:
|
178 |
+
for obb, conf, cls in zip(obb_results.data.cpu().numpy(), obb_results.conf.cpu().numpy(), obb_results.cls.cpu().numpy()):
|
179 |
+
x_center, y_center, width, height, rotation = obb[:5]
|
180 |
+
class_id = int(cls)
|
181 |
+
confidence = float(conf)
|
|
|
|
|
|
|
|
|
182 |
|
183 |
# رسم جعبه چرخان با استفاده از OpenCV
|
184 |
rect = ((x_center, y_center), (width, height), rotation * 180.0 / np.pi) # تبدیل رادیان به درجه
|