Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -62,9 +62,16 @@ class SDRecommender:
|
|
62 |
self.device = "cuda" if torch.cuda.is_available() else "cpu"
|
63 |
print(f"Using device: {self.device}")
|
64 |
|
65 |
-
# Load Florence model and processor
|
66 |
-
|
67 |
-
self.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
68 |
|
69 |
# Load dataset
|
70 |
print("Loading dataset...")
|
@@ -85,7 +92,7 @@ class SDRecommender:
|
|
85 |
|
86 |
# Load trained weights if available
|
87 |
if os.path.exists("recommender_model.pth"):
|
88 |
-
self.model.load_state_dict(torch.load("recommender_model.pth"))
|
89 |
print("Loaded trained model weights")
|
90 |
self.model.eval()
|
91 |
|
|
|
62 |
self.device = "cuda" if torch.cuda.is_available() else "cpu"
|
63 |
print(f"Using device: {self.device}")
|
64 |
|
65 |
+
# Load Florence model and processor dengan trust_remote_code=True
|
66 |
+
print("Loading Florence model and processor...")
|
67 |
+
self.processor = AutoProcessor.from_pretrained(
|
68 |
+
"microsoft/Florence-2-large",
|
69 |
+
trust_remote_code=True
|
70 |
+
)
|
71 |
+
self.florence = AutoModel.from_pretrained(
|
72 |
+
"microsoft/Florence-2-large",
|
73 |
+
trust_remote_code=True
|
74 |
+
)
|
75 |
|
76 |
# Load dataset
|
77 |
print("Loading dataset...")
|
|
|
92 |
|
93 |
# Load trained weights if available
|
94 |
if os.path.exists("recommender_model.pth"):
|
95 |
+
self.model.load_state_dict(torch.load("recommender_model.pth", map_location=self.device))
|
96 |
print("Loaded trained model weights")
|
97 |
self.model.eval()
|
98 |
|