Spaces:
Sleeping
Sleeping
tyrwh
commited on
Commit
·
9315b87
1
Parent(s):
6ad3ec3
fixing tensor.cpu() error in boxes
Browse files- nemaquant.py +3 -3
nemaquant.py
CHANGED
|
@@ -160,7 +160,7 @@ def main():
|
|
| 160 |
box_classes = [result.names[int(x)] for x in result.boxes.cls]
|
| 161 |
# NOTE - filtering by class is not necessary, but would make this easier to extend to multi-class models
|
| 162 |
# e.g. if we want to add hatched, empty eggs, etc
|
| 163 |
-
egg_xy = [x.numpy().astype(np.int32) for i,x in enumerate(result.boxes.xyxy) if box_classes[i] == 'egg']
|
| 164 |
print('Target image:\n%s' % str(args.imgpath))
|
| 165 |
print('n eggs:\n%s' % len(egg_xy))
|
| 166 |
if args.annotated:
|
|
@@ -203,7 +203,7 @@ def main():
|
|
| 203 |
results = model.predict(img, imgsz = 1440, verbose=False, conf=args.conf)
|
| 204 |
result = results[0]
|
| 205 |
box_classes = [result.names[int(x)] for x in result.boxes.cls]
|
| 206 |
-
egg_xy = [x.numpy().astype(np.int32) for i,x in enumerate(result.boxes.xyxy) if box_classes[i] == 'egg']
|
| 207 |
# append relevant output to temporary lists
|
| 208 |
tmp_well.append(well)
|
| 209 |
tmp_numeggs.append(len(egg_xy))
|
|
@@ -240,7 +240,7 @@ def main():
|
|
| 240 |
results = model.predict(img, imgsz = 1440, verbose=False, conf= args.conf)
|
| 241 |
result = results[0]
|
| 242 |
box_classes = [result.names[int(x)] for x in result.boxes.cls]
|
| 243 |
-
egg_xy = [x.numpy().astype(np.int32) for i,x in enumerate(result.boxes.xyxy) if box_classes[i] == 'egg']
|
| 244 |
tmp_numeggs.append(len(egg_xy))
|
| 245 |
tmp_filenames.append(impath.name)
|
| 246 |
# annotate if needed
|
|
|
|
| 160 |
box_classes = [result.names[int(x)] for x in result.boxes.cls]
|
| 161 |
# NOTE - filtering by class is not necessary, but would make this easier to extend to multi-class models
|
| 162 |
# e.g. if we want to add hatched, empty eggs, etc
|
| 163 |
+
egg_xy = [x.cpu().numpy().astype(np.int32) for i,x in enumerate(result.boxes.xyxy) if box_classes[i] == 'egg']
|
| 164 |
print('Target image:\n%s' % str(args.imgpath))
|
| 165 |
print('n eggs:\n%s' % len(egg_xy))
|
| 166 |
if args.annotated:
|
|
|
|
| 203 |
results = model.predict(img, imgsz = 1440, verbose=False, conf=args.conf)
|
| 204 |
result = results[0]
|
| 205 |
box_classes = [result.names[int(x)] for x in result.boxes.cls]
|
| 206 |
+
egg_xy = [x.cpu().numpy().astype(np.int32) for i,x in enumerate(result.boxes.xyxy) if box_classes[i] == 'egg']
|
| 207 |
# append relevant output to temporary lists
|
| 208 |
tmp_well.append(well)
|
| 209 |
tmp_numeggs.append(len(egg_xy))
|
|
|
|
| 240 |
results = model.predict(img, imgsz = 1440, verbose=False, conf= args.conf)
|
| 241 |
result = results[0]
|
| 242 |
box_classes = [result.names[int(x)] for x in result.boxes.cls]
|
| 243 |
+
egg_xy = [x.cpu().numpy().astype(np.int32) for i,x in enumerate(result.boxes.xyxy) if box_classes[i] == 'egg']
|
| 244 |
tmp_numeggs.append(len(egg_xy))
|
| 245 |
tmp_filenames.append(impath.name)
|
| 246 |
# annotate if needed
|