mingyang91 commited on
Commit
71fb5f2
·
verified ·
1 Parent(s): 2c9ef08

remove cv2

Browse files
Files changed (3) hide show
  1. .idea/workspace.xml +14 -5
  2. model.py +4 -8
  3. requirements.txt +0 -1
.idea/workspace.xml CHANGED
@@ -4,9 +4,9 @@
4
  <option name="autoReloadType" value="SELECTIVE" />
5
  </component>
6
  <component name="ChangeListManager">
7
- <list default="true" id="d7806539-b6d6-42e7-bb45-1565f5d54891" name="Changes" comment="init commit">
8
  <change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" />
9
- <change beforePath="$PROJECT_DIR$/Dockerfile" beforeDir="false" afterPath="$PROJECT_DIR$/Dockerfile" afterDir="false" />
10
  <change beforePath="$PROJECT_DIR$/requirements.txt" beforeDir="false" afterPath="$PROJECT_DIR$/requirements.txt" afterDir="false" />
11
  </list>
12
  <option name="SHOW_DIALOG" value="false" />
@@ -119,7 +119,7 @@
119
  <option name="presentableId" value="Default" />
120
  <updated>1702301546100</updated>
121
  <workItem from="1702301554378" duration="4025000" />
122
- <workItem from="1702450051021" duration="1074000" />
123
  </task>
124
  <task id="LOCAL-00001" summary="init commit">
125
  <option name="closed" value="true" />
@@ -129,7 +129,15 @@
129
  <option name="project" value="LOCAL" />
130
  <updated>1702450645297</updated>
131
  </task>
132
- <option name="localTasksCounter" value="2" />
 
 
 
 
 
 
 
 
133
  <servers />
134
  </component>
135
  <component name="TypeScriptGeneratedFilesManager">
@@ -137,7 +145,8 @@
137
  </component>
138
  <component name="VcsManagerConfiguration">
139
  <MESSAGE value="init commit" />
140
- <option name="LAST_COMMIT_MESSAGE" value="init commit" />
 
141
  </component>
142
  <component name="com.intellij.coverage.CoverageDataManagerImpl">
143
  <SUITE FILE_PATH="coverage/detector$demo.coverage" NAME="demo Coverage Results" MODIFIED="1702302380580" SOURCE_PROVIDER="com.intellij.coverage.DefaultCoverageFileProvider" RUNNER="coverage.py" COVERAGE_BY_TEST_ENABLED="true" COVERAGE_TRACING_ENABLED="false" WORKING_DIRECTORY="$PROJECT_DIR$" />
 
4
  <option name="autoReloadType" value="SELECTIVE" />
5
  </component>
6
  <component name="ChangeListManager">
7
+ <list default="true" id="d7806539-b6d6-42e7-bb45-1565f5d54891" name="Changes" comment="fix build">
8
  <change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" />
9
+ <change beforePath="$PROJECT_DIR$/model.py" beforeDir="false" afterPath="$PROJECT_DIR$/model.py" afterDir="false" />
10
  <change beforePath="$PROJECT_DIR$/requirements.txt" beforeDir="false" afterPath="$PROJECT_DIR$/requirements.txt" afterDir="false" />
11
  </list>
12
  <option name="SHOW_DIALOG" value="false" />
 
119
  <option name="presentableId" value="Default" />
120
  <updated>1702301546100</updated>
121
  <workItem from="1702301554378" duration="4025000" />
122
+ <workItem from="1702450051021" duration="2218000" />
123
  </task>
124
  <task id="LOCAL-00001" summary="init commit">
125
  <option name="closed" value="true" />
 
129
  <option name="project" value="LOCAL" />
130
  <updated>1702450645297</updated>
131
  </task>
132
+ <task id="LOCAL-00002" summary="fix build">
133
+ <option name="closed" value="true" />
134
+ <created>1702451179622</created>
135
+ <option name="number" value="00002" />
136
+ <option name="presentableId" value="LOCAL-00002" />
137
+ <option name="project" value="LOCAL" />
138
+ <updated>1702451179622</updated>
139
+ </task>
140
+ <option name="localTasksCounter" value="3" />
141
  <servers />
142
  </component>
143
  <component name="TypeScriptGeneratedFilesManager">
 
145
  </component>
146
  <component name="VcsManagerConfiguration">
147
  <MESSAGE value="init commit" />
148
+ <MESSAGE value="fix build" />
149
+ <option name="LAST_COMMIT_MESSAGE" value="fix build" />
150
  </component>
151
  <component name="com.intellij.coverage.CoverageDataManagerImpl">
152
  <SUITE FILE_PATH="coverage/detector$demo.coverage" NAME="demo Coverage Results" MODIFIED="1702302380580" SOURCE_PROVIDER="com.intellij.coverage.DefaultCoverageFileProvider" RUNNER="coverage.py" COVERAGE_BY_TEST_ENABLED="true" COVERAGE_TRACING_ENABLED="false" WORKING_DIRECTORY="$PROJECT_DIR$" />
model.py CHANGED
@@ -1,9 +1,8 @@
1
-
2
- import cv2
3
  import torch
4
  import random
5
  from PIL import ImageDraw
6
  import torchvision.transforms as T
 
7
 
8
  # COCO Classes
9
  CLASSES = [
@@ -69,10 +68,9 @@ def plot_one_box(x, img, color=None, label=None, line_thickness=None):
69
  img_draw.rectangle((c1[0], c1[1], c2[0], c2[1]), outline=color, width=tl)
70
  if label:
71
  tf = max(tl - 1, 1) # font thickness
72
- t_size = cv2.getTextSize(label, 0, fontScale=tl / 5, thickness=tf)[0]
73
- c2 = c1[0] + t_size[0], c1[1] + t_size[1] - 3
74
- img_draw.rectangle((c1, c2), fill=color)
75
- img_draw.text((c1[0], c1[1] - 2), label, fill=(255, 255, 255))
76
 
77
 
78
  # Ploting Bounding Box on img
@@ -91,8 +89,6 @@ def detect(im, confidence):
91
  model.eval()
92
 
93
  scores, boxes = image_processing(im, model, transform, confidence / 100)
94
- # im = cv2.imread(image_path)
95
- # im = cv2.cvtColor(im, cv2.COLOR_BGR2RGB)
96
  im = add_bboxes(im, scores, boxes)
97
 
98
  return im
 
 
 
1
  import torch
2
  import random
3
  from PIL import ImageDraw
4
  import torchvision.transforms as T
5
+ from PIL.ImageFont import ImageFont, truetype
6
 
7
  # COCO Classes
8
  CLASSES = [
 
68
  img_draw.rectangle((c1[0], c1[1], c2[0], c2[1]), outline=color, width=tl)
69
  if label:
70
  tf = max(tl - 1, 1) # font thickness
71
+ x1, y1, x2, y2 = img_draw.textbbox(c1, label, stroke_width=tf)
72
+ img_draw.rectangle((x1, y1, x2, y2), fill=color)
73
+ img_draw.text((x1, y1), label, fill=(255, 255, 255))
 
74
 
75
 
76
  # Ploting Bounding Box on img
 
89
  model.eval()
90
 
91
  scores, boxes = image_processing(im, model, transform, confidence / 100)
 
 
92
  im = add_bboxes(im, scores, boxes)
93
 
94
  return im
requirements.txt CHANGED
@@ -26,7 +26,6 @@ mdurl==0.1.2
26
  mpmath==1.3.0
27
  networkx==3.2.1
28
  numpy==1.26.2
29
- opencv-python==4.8.1.78
30
  packaging==23.2
31
  pandas==2.1.4
32
  Pillow==10.1.0
 
26
  mpmath==1.3.0
27
  networkx==3.2.1
28
  numpy==1.26.2
 
29
  packaging==23.2
30
  pandas==2.1.4
31
  Pillow==10.1.0