Spaces:
Sleeping
Sleeping
Update main.py
Browse files
main.py
CHANGED
|
@@ -40,6 +40,9 @@ recog_session = ort.InferenceSession(recog_path_local)
|
|
| 40 |
df = pd.read_parquet(card_data_path)
|
| 41 |
ref_embeddings = np.vstack(df['embedding'].values).astype(np.float32)
|
| 42 |
|
|
|
|
|
|
|
|
|
|
| 43 |
task_config = {
|
| 44 |
"recog": {"image_width": 160, "image_height": 224, "means": [0.5, 0.5, 0.5], "stds": [0.5, 0.5, 0.5]},
|
| 45 |
"corner": {"image_width": 256, "image_height": 256, "means": [0.5, 0.5, 0.5], "stds": [0.5, 0.5, 0.5]},
|
|
@@ -179,7 +182,7 @@ async def predict(file: UploadFile = File(...)) -> Card:
|
|
| 179 |
best_sim = float(similarities[best_idx])
|
| 180 |
|
| 181 |
# Retrieve card metadata from dataframe using integer position
|
| 182 |
-
card_info =
|
| 183 |
|
| 184 |
# End timing
|
| 185 |
t1 = time.perf_counter()
|
|
|
|
| 40 |
df = pd.read_parquet(card_data_path)
|
| 41 |
ref_embeddings = np.vstack(df['embedding'].values).astype(np.float32)
|
| 42 |
|
| 43 |
+
card_metadata = df[['card_id', 'name', 'uri', 'card_url', 'image_url', 'lang', 'rarity', 'set_name', 'set']].to_dict('records')
|
| 44 |
+
del df # Free DataFrame memory after extracting needed data
|
| 45 |
+
|
| 46 |
task_config = {
|
| 47 |
"recog": {"image_width": 160, "image_height": 224, "means": [0.5, 0.5, 0.5], "stds": [0.5, 0.5, 0.5]},
|
| 48 |
"corner": {"image_width": 256, "image_height": 256, "means": [0.5, 0.5, 0.5], "stds": [0.5, 0.5, 0.5]},
|
|
|
|
| 182 |
best_sim = float(similarities[best_idx])
|
| 183 |
|
| 184 |
# Retrieve card metadata from dataframe using integer position
|
| 185 |
+
card_info = card_metadata[best_idx]
|
| 186 |
|
| 187 |
# End timing
|
| 188 |
t1 = time.perf_counter()
|