Spaces:
Sleeping
Sleeping
dron3flyv3r
commited on
Commit
•
296a3ff
1
Parent(s):
5862992
Update read.py
Browse files
read.py
CHANGED
@@ -1,13 +1,9 @@
|
|
1 |
-
import random
|
2 |
import torch
|
3 |
from PIL import Image
|
4 |
-
import requests
|
5 |
|
6 |
-
def classify(model,
|
7 |
-
|
8 |
try:
|
9 |
model = model.eval()
|
10 |
-
img = imgPath
|
11 |
img = img.convert("RGB")
|
12 |
img = trans(img)
|
13 |
img = img.unsqueeze(0)
|
@@ -19,10 +15,4 @@ def classify(model, imgPath, trans=None, classes=[], device=torch.device("cpu"))
|
|
19 |
|
20 |
return f"It {classes[pred.item()]} i'm {procent[0][pred[0]]*100:.2f}% sure"
|
21 |
except Exception:
|
22 |
-
return "Something went wrong😕, please notify the developer with the following message: " + str(Exception)
|
23 |
-
|
24 |
-
|
25 |
-
def get_random_quote():
|
26 |
-
with open("quotes.txt", "r") as file:
|
27 |
-
quotes = file.readlines()
|
28 |
-
return quotes[random.randint(0, len(quotes)-1)]
|
|
|
|
|
1 |
import torch
|
2 |
from PIL import Image
|
|
|
3 |
|
4 |
+
def classify(model, img, trans=None, classes=[], device=torch.device("cpu")):
|
|
|
5 |
try:
|
6 |
model = model.eval()
|
|
|
7 |
img = img.convert("RGB")
|
8 |
img = trans(img)
|
9 |
img = img.unsqueeze(0)
|
|
|
15 |
|
16 |
return f"It {classes[pred.item()]} i'm {procent[0][pred[0]]*100:.2f}% sure"
|
17 |
except Exception:
|
18 |
+
return "Something went wrong😕, please notify the developer with the following message: " + str(Exception)
|
|
|
|
|
|
|
|
|
|
|
|