radames commited on
Commit
5f2948a
1 Parent(s): 67008b9

better retry for models with noe image

Browse files
Files changed (1) hide show
  1. app.py +10 -2
app.py CHANGED
@@ -194,8 +194,16 @@ async def sync_data():
194
  with database.get_db() as db:
195
  cursor = db.cursor()
196
  cursor.execute(
197
- "SELECT * from models WHERE json_array_length(data, '$.images') < 1;")
198
- models_no_images = list(cursor.fetchall())
 
 
 
 
 
 
 
 
199
  for model in tqdm(models_no_images):
200
  model_id = model['id']
201
  model_data = json.loads(model['data'])
 
194
  with database.get_db() as db:
195
  cursor = db.cursor()
196
  cursor.execute(
197
+ "SELECT * from models")
198
+ all_models = list(cursor.fetchall())
199
+ models_no_images = []
200
+ for model in all_models:
201
+ model_data = json.loads(model['data'])
202
+ images = model_data['images']
203
+ filtered_images = [x for x in images if x is not None]
204
+ if len(filtered_images) == 0:
205
+ models_no_images.append(model)
206
+
207
  for model in tqdm(models_no_images):
208
  model_id = model['id']
209
  model_data = json.loads(model['data'])