Spaces:
Sleeping
Sleeping
rynmurdock
commited on
Commit
·
0133d9c
1
Parent(s):
c622fea
Update app.py
Browse files
app.py
CHANGED
@@ -254,21 +254,23 @@ def background_next_image():
|
|
254 |
|
255 |
user_emb = get_user_emb(embs, ys)
|
256 |
img, embs = generate(user_emb)
|
257 |
-
|
258 |
-
|
259 |
-
|
260 |
-
|
261 |
-
|
262 |
-
|
263 |
-
|
264 |
-
|
265 |
-
if
|
266 |
-
|
267 |
-
|
268 |
-
|
269 |
-
|
270 |
-
|
271 |
-
|
|
|
|
|
272 |
|
273 |
|
274 |
def pluck_embs_ys(user_id):
|
|
|
254 |
|
255 |
user_emb = get_user_emb(embs, ys)
|
256 |
img, embs = generate(user_emb)
|
257 |
+
print(img)
|
258 |
+
if img:
|
259 |
+
tmp_df = pd.DataFrame(columns=['paths', 'embeddings', 'ips', 'user:rating', 'latest_user_to_rate'])
|
260 |
+
tmp_df['paths'] = [img]
|
261 |
+
tmp_df['embeddings'] = [embs]
|
262 |
+
tmp_df['user:rating'] = [{' ': ' '}]
|
263 |
+
prevs_df = pd.concat((prevs_df, tmp_df))
|
264 |
+
# we can free up storage by deleting the image
|
265 |
+
if len(prevs_df) > 50:
|
266 |
+
oldest_path = prevs_df.iloc[0]['paths']
|
267 |
+
if os.path.isfile(oldest_path):
|
268 |
+
os.remove(oldest_path)
|
269 |
+
else:
|
270 |
+
# If it fails, inform the user.
|
271 |
+
print("Error: %s file not found" % oldest_path)
|
272 |
+
# only keep 50 images & embeddings & ips, then remove oldest
|
273 |
+
prevs_df = prevs_df.iloc[1:]
|
274 |
|
275 |
|
276 |
def pluck_embs_ys(user_id):
|