rynmurdock commited on
Commit
0133d9c
·
1 Parent(s): c622fea

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +17 -15
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
- tmp_df = pd.DataFrame(columns=['paths', 'embeddings', 'ips', 'user:rating', 'latest_user_to_rate'])
258
- tmp_df['paths'] = [img]
259
- tmp_df['embeddings'] = [embs]
260
- tmp_df['user:rating'] = [{' ': ' '}]
261
- prevs_df = pd.concat((prevs_df, tmp_df))
262
- # we can free up storage by deleting the image
263
- if len(prevs_df) > 50:
264
- oldest_path = prevs_df.iloc[0]['paths']
265
- if os.path.isfile(oldest_path):
266
- os.remove(oldest_path)
267
- else:
268
- # If it fails, inform the user.
269
- print("Error: %s file not found" % oldest_path)
270
- # only keep 50 images & embeddings & ips, then remove oldest
271
- prevs_df = prevs_df.iloc[1:]
 
 
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):