mylesai commited on
Commit
d8cda22
·
1 Parent(s): aaddf35

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +17 -27
app.py CHANGED
@@ -182,7 +182,7 @@ def get_seo_tags(image_path, topical_map, attempts=0):
182
  if json_dict['topic'] not in topic_list:
183
  print('wrong_topic')
184
  attempts += 1
185
- get_seo_tags(image_path, topical_map)
186
 
187
  test = json_dict['seo']
188
  if set(json_dict.keys()) == set(keys):
@@ -275,21 +275,24 @@ def create_asset(client_name, collection_id, image_path, topical_map, new_imgs,
275
  Output: id of asset
276
  '''
277
 
278
- # # get seo, topic, and sub-topic from OpenAI API
279
- # json_dict = get_seo_tags(image_path, topical_map)
 
 
 
280
 
281
 
282
- # topic = json_dict['topic']
283
- # description = json_dict['description']
284
- # caption = json_dict['caption']
285
- # seo_tags = json_dict['seo']
286
- # alt_tag = json_dict['alt_tag']
287
- # image_name = json_dict['filename']
288
 
289
- # counter = 1
290
- # while image_name in new_imgs:
291
- # image_name = f'{image_name}_{counter}'
292
- # counter += 1
293
 
294
 
295
  headers = {
@@ -328,19 +331,6 @@ def create_asset(client_name, collection_id, image_path, topical_map, new_imgs,
328
  # get seo, topic, and sub-topic from OpenAI API
329
  json_dict = get_seo_tags(temp_image, topical_map)
330
 
331
-
332
- topic = json_dict['topic']
333
- description = json_dict['description']
334
- caption = json_dict['caption']
335
- seo_tags = json_dict['seo']
336
- alt_tag = json_dict['alt_tag']
337
- image_name = json_dict['filename']
338
-
339
- counter = 1
340
- while image_name in new_imgs:
341
- image_name = f'{image_name}_{counter}'
342
- counter += 1
343
-
344
  # posts image with image name
345
 
346
  r = requests.post(f'https://brandfolder.com/api/v4/collections/{collection_id}/assets', json={
@@ -494,7 +484,7 @@ def create_asset(client_name, collection_id, image_path, topical_map, new_imgs,
494
  , params={
495
  }, headers=headers)
496
 
497
- return
498
 
499
  def create_collection(collection_name):
500
  '''
 
182
  if json_dict['topic'] not in topic_list:
183
  print('wrong_topic')
184
  attempts += 1
185
+ get_seo_tags(image_path, topical_map, attempts)
186
 
187
  test = json_dict['seo']
188
  if set(json_dict.keys()) == set(keys):
 
275
  Output: id of asset
276
  '''
277
 
278
+ # get seo, topic, and sub-topic from OpenAI API
279
+ try:
280
+ json_dict = get_seo_tags(image_path, topical_map)
281
+ except:
282
+ return image_path
283
 
284
 
285
+ topic = json_dict['topic']
286
+ description = json_dict['description']
287
+ caption = json_dict['caption']
288
+ seo_tags = json_dict['seo']
289
+ alt_tag = json_dict['alt_tag']
290
+ image_name = json_dict['filename']
291
 
292
+ counter = 1
293
+ while image_name in new_imgs:
294
+ image_name = f'{image_name}_{counter}'
295
+ counter += 1
296
 
297
 
298
  headers = {
 
331
  # get seo, topic, and sub-topic from OpenAI API
332
  json_dict = get_seo_tags(temp_image, topical_map)
333
 
 
 
 
 
 
 
 
 
 
 
 
 
 
334
  # posts image with image name
335
 
336
  r = requests.post(f'https://brandfolder.com/api/v4/collections/{collection_id}/assets', json={
 
484
  , params={
485
  }, headers=headers)
486
 
487
+ return image_name
488
 
489
  def create_collection(collection_name):
490
  '''