Spaces:
Runtime error
Runtime error
Commit
·
5a69773
1
Parent(s):
7d4b686
Update main.py
Browse files
main.py
CHANGED
|
@@ -1,6 +1,7 @@
|
|
| 1 |
from fastapi import FastAPI
|
| 2 |
from pydantic import BaseModel
|
| 3 |
from typing import List
|
|
|
|
| 4 |
|
| 5 |
class Item(BaseModel):
|
| 6 |
name: str
|
|
@@ -29,7 +30,7 @@ def predict(item: Item):
|
|
| 29 |
# encoded_image = model.encode(Image.open(filepath))
|
| 30 |
#image_names = list(glob.glob('./*.jpg'))
|
| 31 |
#print("Images:", len(image_names))
|
| 32 |
-
encoded_image = model.encode([item.image1, item.image2], batch_size=128, convert_to_tensor=True, show_progress_bar=True)
|
| 33 |
|
| 34 |
# Now we run the clustering algorithm. This function compares images aganist
|
| 35 |
# all other images and returns a list with the pairs that have the highest
|
|
|
|
| 1 |
from fastapi import FastAPI
|
| 2 |
from pydantic import BaseModel
|
| 3 |
from typing import List
|
| 4 |
+
from PIL import Image
|
| 5 |
|
| 6 |
class Item(BaseModel):
|
| 7 |
name: str
|
|
|
|
| 30 |
# encoded_image = model.encode(Image.open(filepath))
|
| 31 |
#image_names = list(glob.glob('./*.jpg'))
|
| 32 |
#print("Images:", len(image_names))
|
| 33 |
+
encoded_image = model.encode([Image.open(item.image1), Image.open(item.image2)], batch_size=128, convert_to_tensor=True, show_progress_bar=True)
|
| 34 |
|
| 35 |
# Now we run the clustering algorithm. This function compares images aganist
|
| 36 |
# all other images and returns a list with the pairs that have the highest
|