Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -48,25 +48,10 @@ transform = transforms.Compose([
|
|
48 |
OBJECT_NAMES = ['enemies']
|
49 |
|
50 |
|
51 |
-
|
52 |
-
# Ensure image is a PIL Image
|
53 |
-
data = Image.fromarray(image)
|
54 |
-
|
55 |
-
if isinstance(data, torch.Tensor):
|
56 |
-
print("hey")
|
57 |
-
image = transforms.ToPILImage()(data) # Convert tensor to PIL image
|
58 |
-
|
59 |
-
if isinstance(data, Image.Image):
|
60 |
-
print("hey2")
|
61 |
-
orig_w, orig_h = data.size # PIL image size returns (width, height)
|
62 |
-
else:
|
63 |
-
raise TypeError(f"Expected a PIL Image but got ")
|
64 |
-
print(type(image))
|
65 |
-
print(type(data))
|
66 |
-
exit()
|
67 |
-
|
68 |
-
# Apply transformation
|
69 |
img_tensor = transform(image).unsqueeze(0)
|
|
|
|
|
70 |
|
71 |
with torch.no_grad():
|
72 |
pred = model(img_tensor)[0]
|
|
|
48 |
OBJECT_NAMES = ['enemies']
|
49 |
|
50 |
|
51 |
+
ef detect_objects_in_image(image):
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
52 |
img_tensor = transform(image).unsqueeze(0)
|
53 |
+
orig_w, orig_h = image.size
|
54 |
+
|
55 |
|
56 |
with torch.no_grad():
|
57 |
pred = model(img_tensor)[0]
|