tunght commited on
Commit
8a72398
·
1 Parent(s): f9cb324

Fix get img features

Browse files
Files changed (1) hide show
  1. app.py +21 -4
app.py CHANGED
@@ -419,7 +419,15 @@ Return the product description only.
419
  </included_phrases>"""
420
 
421
 
422
- detect_feature_prompt = """Describe the features of the {garment_type} in the photo in less than 150 words.\nReturn the result in in the following JSON format without any preceding or trailing text:\n\n{{\n \"features\": [list of comma separated features],\n \"intended_use\": [list of comma separated intended uses],\n \"alt_text\": alt text for the image,\n \"category\": the category of the garment, for example 'dress', 'shirt', 'pants', 'shoes', etc\n}}"""
 
 
 
 
 
 
 
 
423
 
424
 
425
  import base64
@@ -539,9 +547,18 @@ def detect_features(image_paths, garment_type, language="English"):
539
 
540
  response = chat.batch(messages)
541
 
542
- print("image features", response)
543
- # print("image features", response["choices"][0]['message']['content'])
544
- jresponse = get_json(response[0].content)
 
 
 
 
 
 
 
 
 
545
  return jresponse, base64_images
546
  except Exception as e:
547
  print(e.__class__, e)
 
419
  </included_phrases>"""
420
 
421
 
422
+ detect_feature_prompt = """Describe the features of the {garment_type} in the photo in less than 150 words.
423
+ Return the result in in the following JSON format without any preceding or trailing text:
424
+
425
+ {{
426
+ \"features\": [list of comma separated features],
427
+ \"intended_use\": [list of comma separated intended uses],
428
+ \"alt_text\": alt text for the image,
429
+ \"category\": the category of the garment, for example 'dress', 'shirt', 'pants', 'shoes', etc\n
430
+ }}"""
431
 
432
 
433
  import base64
 
547
 
548
  response = chat.batch(messages)
549
 
550
+ print("image features")
551
+ jresponse = {}
552
+ for resp in response:
553
+ print(resp.content)
554
+ print()
555
+ jresponse_i = get_json(response[0].content)
556
+ jresponse["features"] = jresponse.get("features", []) + jresponse_i.get("features", [])
557
+ jresponse["intended_use"] = jresponse.get("intended_use", []) + jresponse_i.get("intended_use", [])
558
+ jresponse["alt_text"] = jresponse.get("alt_text", []) + [jresponse_i.get("alt_text", "")]
559
+
560
+
561
+
562
  return jresponse, base64_images
563
  except Exception as e:
564
  print(e.__class__, e)