Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -50,13 +50,15 @@ OBJECT_NAMES = ['enemies']
|
|
| 50 |
|
| 51 |
def detect_objects_in_image(image):
|
| 52 |
# Ensure image is a PIL Image
|
| 53 |
-
|
| 54 |
|
| 55 |
if isinstance(image, torch.Tensor):
|
| 56 |
-
|
|
|
|
| 57 |
|
| 58 |
if isinstance(image, Image.Image):
|
| 59 |
-
|
|
|
|
| 60 |
else:
|
| 61 |
raise TypeError(f"Expected a PIL Image but got ")
|
| 62 |
print(type(image))
|
|
|
|
| 50 |
|
| 51 |
def detect_objects_in_image(image):
|
| 52 |
# Ensure image is a PIL Image
|
| 53 |
+
data = Image.fromarray(image)
|
| 54 |
|
| 55 |
if isinstance(image, torch.Tensor):
|
| 56 |
+
print("hey")
|
| 57 |
+
image = transforms.ToPILImage()(data) # Convert tensor to PIL image
|
| 58 |
|
| 59 |
if isinstance(image, 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))
|