tunght commited on
Commit
b40288d
1 Parent(s): b4bdfb1

fix size and weight hallucination. Problem: cannot detect image feature with the old prompt

Browse files
Files changed (1) hide show
  1. app.py +13 -13
app.py CHANGED
@@ -37,6 +37,7 @@ Brushed wool-blend melton coat.
37
  路 Welt pocket and flap pockets
38
  路 Padded shoulders
39
  路 Size 30 x 20 x 60 cm
 
40
  路 Four-button surgeon's cuffs
41
  路 TextPatch at cuff
42
  路 Logo cutout at back collar
@@ -147,12 +148,8 @@ def detect_features(image_paths, garment_type, language="English"):
147
  "content": [
148
  {
149
  "type": "text",
150
- "text": f"""Describe the features of the {garment_type} in the photos in less than 100 words.
151
- What is the intended use of the {garment_type} in this image, use at most 5 words for intended use?
152
- Generate alt text for each of the images.
153
- Make sure to output the alt text in {language} language.
154
- If the photo does not contain a garment, return 'No garment detected'.
155
- If the photo contains a garment, return the result in in the following JSON format without any preceding or trailing text:
156
 
157
  {{
158
  "features": [list of comma separated features],
@@ -343,7 +340,7 @@ def generate(*data):
343
  if image_features is not None and len(image_features) > 0:
344
  alt_texts = image_features["alt_text"]
345
  detected_features = ", ".join(image_features["features"])
346
- intended_use = "Intended use: " + ", ".join(image_features["intended_use"])
347
  print(f"Detected features: {detected_features}, Intended use: {intended_use}, Alt text: {alt_texts}")
348
 
349
  # if glossary:
@@ -376,7 +373,7 @@ Do not use the structure of the reference copy in the output.
376
  Do not use any of the excluded words in the output.
377
  Include all included words in the output.
378
  Do not hallucinate any information.
379
- Do not hallucinate information about size. Write about size only if it is available in the list of features.
380
  Use creative language in each output, do not use the common ways of starting product descriptions.
381
  Avoid common phrases and cliches such as "Step into something", "Elevate something", "Discover something", "Unleash something", "Embrace something", and similar phrases.
382
  For each version, try to write in different style.
@@ -414,7 +411,8 @@ Return the result in the following JSON format:
414
  Make sure that the output is in JSON format, no extra text should be included in the output.
415
 
416
  Product information:
417
- Key features: {feature + detected_features}
 
418
 
419
  Intended use: {intended_use}
420
 
@@ -441,7 +439,7 @@ Make sure that the structure of each output follows the structure of the referen
441
  Do not use any of the excluded words in the output.
442
  Include all included words in the output.
443
  Do not hallucinate any information.
444
- Do not hallucinate information about size. Write about size only if it is available in the list of features.
445
  Use creative language in each output, do not use the common ways of starting product descriptions.
446
  Avoid common phrases and cliches such as "Step into something", "Elevate something", "Discover something", "Unleash something", "Embrace something", and similar phrases.
447
  For each version, try to write in different style.
@@ -478,7 +476,8 @@ Return the result in the following JSON format:
478
  Make sure that the output is in JSON format, no extra text should be included in the output.
479
 
480
  Product information:
481
- Key features: {feature + detected_features}
 
482
 
483
  Intended use: {intended_use}
484
 
@@ -505,7 +504,7 @@ Make sure that the structure of each output follows the reference structure.
505
  Do not use any of the excluded words in the output.
506
  Include all included words in the output.
507
  Do not hallucinate any information.
508
- Do not hallucinate information about size. Write about size only if it is available in the list of features.
509
  Use creative language in each output, do not use the common ways of starting product descriptions.
510
  Avoid common phrases and cliches such as "Step into something", "Elevate something", "Discover something", "Unleash something", "Embrace something", and similar phrases.
511
  For each version, try to write in different style.
@@ -542,7 +541,8 @@ Return the result in the following JSON format:
542
  Make sure that the output is in JSON format, no extra text should be included in the output.
543
 
544
  Product information:
545
- Key features: {feature + detected_features}
 
546
 
547
  Intended use: {intended_use}
548
 
 
37
  路 Welt pocket and flap pockets
38
  路 Padded shoulders
39
  路 Size 30 x 20 x 60 cm
40
+ 路 Weight only 9kg
41
  路 Four-button surgeon's cuffs
42
  路 TextPatch at cuff
43
  路 Logo cutout at back collar
 
148
  "content": [
149
  {
150
  "type": "text",
151
+ "text": f"""Describe the features of the {garment_type} in the photos.
152
+ Return the result in in the following JSON format without any preceding or trailing text:
 
 
 
 
153
 
154
  {{
155
  "features": [list of comma separated features],
 
340
  if image_features is not None and len(image_features) > 0:
341
  alt_texts = image_features["alt_text"]
342
  detected_features = ", ".join(image_features["features"])
343
+ intended_use = ", ".join(image_features["intended_use"])
344
  print(f"Detected features: {detected_features}, Intended use: {intended_use}, Alt text: {alt_texts}")
345
 
346
  # if glossary:
 
373
  Do not use any of the excluded words in the output.
374
  Include all included words in the output.
375
  Do not hallucinate any information.
376
+ Do not hallucinate information about size and weight. Write about size and weight only if it is available in the list of features.
377
  Use creative language in each output, do not use the common ways of starting product descriptions.
378
  Avoid common phrases and cliches such as "Step into something", "Elevate something", "Discover something", "Unleash something", "Embrace something", and similar phrases.
379
  For each version, try to write in different style.
 
411
  Make sure that the output is in JSON format, no extra text should be included in the output.
412
 
413
  Product information:
414
+ Key features: {feature}
415
+ {detected_features}
416
 
417
  Intended use: {intended_use}
418
 
 
439
  Do not use any of the excluded words in the output.
440
  Include all included words in the output.
441
  Do not hallucinate any information.
442
+ Do not hallucinate information about size and weight. Write about size and weight only if it is available in the list of features.
443
  Use creative language in each output, do not use the common ways of starting product descriptions.
444
  Avoid common phrases and cliches such as "Step into something", "Elevate something", "Discover something", "Unleash something", "Embrace something", and similar phrases.
445
  For each version, try to write in different style.
 
476
  Make sure that the output is in JSON format, no extra text should be included in the output.
477
 
478
  Product information:
479
+ Key features: {feature}
480
+ {detected_features}
481
 
482
  Intended use: {intended_use}
483
 
 
504
  Do not use any of the excluded words in the output.
505
  Include all included words in the output.
506
  Do not hallucinate any information.
507
+ Do not hallucinate information about size and weight. Write about size and weight only if it is available in the list of features.
508
  Use creative language in each output, do not use the common ways of starting product descriptions.
509
  Avoid common phrases and cliches such as "Step into something", "Elevate something", "Discover something", "Unleash something", "Embrace something", and similar phrases.
510
  For each version, try to write in different style.
 
541
  Make sure that the output is in JSON format, no extra text should be included in the output.
542
 
543
  Product information:
544
+ Key features: {feature}
545
+ {detected_features}
546
 
547
  Intended use: {intended_use}
548