Spaces:
Runtime error
Runtime error
Commit ·
80a1838
1
Parent(s): 5f4f9b7
Update app.py
Browse filessuppression de load_index et flickr
app.py
CHANGED
|
@@ -9,7 +9,7 @@ import requests
|
|
| 9 |
import torch
|
| 10 |
|
| 11 |
from request import get_ft, get_topk
|
| 12 |
-
from flickrapi import FlickrAPI
|
| 13 |
|
| 14 |
from flask import Flask, request, render_template, jsonify, send_from_directory
|
| 15 |
app = Flask(__name__)
|
|
@@ -21,16 +21,16 @@ PRESET_IMAGES = {
|
|
| 21 |
}
|
| 22 |
|
| 23 |
# Add Flickr configuration
|
| 24 |
-
FLICKR_API_KEY = '80ef21a6f7eb0984ea613c316a89ca69'
|
| 25 |
-
FLICKR_API_SECRET = '4d0e8ce6734f4b3f'
|
| 26 |
-
flickr = FlickrAPI(FLICKR_API_KEY, FLICKR_API_SECRET, format='parsed-json', store_token=False)
|
| 27 |
|
| 28 |
-
def get_photo_id(url):
|
| 29 |
-
"""Extract photo ID from Flickr URL"""
|
| 30 |
-
try:
|
| 31 |
-
return url.split('/')[-1].split('_')[0]
|
| 32 |
-
except:
|
| 33 |
-
return None
|
| 34 |
|
| 35 |
### def get_other_info(url):
|
| 36 |
### """Get author information from Flickr"""
|
|
@@ -67,9 +67,9 @@ def get_photo_id(url):
|
|
| 67 |
### model.to(torch.device('cuda' if torch.cuda.is_available() else 'cpu'))
|
| 68 |
### return model
|
| 69 |
|
| 70 |
-
def load_index(index_path):
|
| 71 |
-
"""Load FAISS index once and cache it"""
|
| 72 |
-
return faiss.read_index(index_path)
|
| 73 |
|
| 74 |
def distance_to_similarity(distances, temp=1e-4):
|
| 75 |
"""Convert distance to similarity"""
|
|
|
|
| 9 |
import torch
|
| 10 |
|
| 11 |
from request import get_ft, get_topk
|
| 12 |
+
### from flickrapi import FlickrAPI
|
| 13 |
|
| 14 |
from flask import Flask, request, render_template, jsonify, send_from_directory
|
| 15 |
app = Flask(__name__)
|
|
|
|
| 21 |
}
|
| 22 |
|
| 23 |
# Add Flickr configuration
|
| 24 |
+
### FLICKR_API_KEY = '80ef21a6f7eb0984ea613c316a89ca69'
|
| 25 |
+
### FLICKR_API_SECRET = '4d0e8ce6734f4b3f'
|
| 26 |
+
### flickr = FlickrAPI(FLICKR_API_KEY, FLICKR_API_SECRET, format='parsed-json', store_token=False)
|
| 27 |
|
| 28 |
+
### def get_photo_id(url):
|
| 29 |
+
### """Extract photo ID from Flickr URL"""
|
| 30 |
+
### try:
|
| 31 |
+
### return url.split('/')[-1].split('_')[0]
|
| 32 |
+
### except:
|
| 33 |
+
### return None
|
| 34 |
|
| 35 |
### def get_other_info(url):
|
| 36 |
### """Get author information from Flickr"""
|
|
|
|
| 67 |
### model.to(torch.device('cuda' if torch.cuda.is_available() else 'cpu'))
|
| 68 |
### return model
|
| 69 |
|
| 70 |
+
### def load_index(index_path):
|
| 71 |
+
### """Load FAISS index once and cache it"""
|
| 72 |
+
### return faiss.read_index(index_path)
|
| 73 |
|
| 74 |
def distance_to_similarity(distances, temp=1e-4):
|
| 75 |
"""Convert distance to similarity"""
|