miaw1419 commited on
Commit
b83da92
1 Parent(s): 2b0ebe1

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +6 -7
app.py CHANGED
@@ -303,9 +303,9 @@ with gr.Blocks(css=css, title="ViPer Demo", theme=gr.themes.Base()) as demo:
303
  if len(comments) < 8:
304
  gr.Warning("Fewer than 8 comments may lead to errors.")
305
 
306
- #keys = list(comments.keys())
307
- #random.shuffle(keys)
308
- #comments = dict([(key, comments[key]) for key in keys])
309
 
310
  prompt = """I will provide a set of artworks along with accompanying comments from a person. Analyze these artworks and the comments on them and identify artistic features such as present or mentioned colors, style, composition, mood, medium, texture, brushwork, lighting, shadow effects, perspective, and other noteworthy elements.
311
  Your task is to extract the artistic features the person likes and dislikes based on both the artworks' features and the person's comments. Focus solely on artistic aspects and refrain from considering subject matter.
@@ -346,8 +346,6 @@ with gr.Blocks(css=css, title="ViPer Demo", theme=gr.themes.Base()) as demo:
346
  generated_ids = vpe_model.generate(**inputs, max_new_tokens=2000, repetition_penalty=0.99, do_sample=False)
347
  generated_texts = processor.batch_decode(generated_ids, skip_special_tokens=True)[0]
348
 
349
- print(generated_texts)
350
-
351
  if re.match(r"(.|\n)*Assistant: Liked Art Features: (.|\n)*Disliked Art Features: (.|\n)*", generated_texts):
352
  positive_vp, negative_vp = re.search('.* \nAssistant: Liked Art Features: (.*)\nDisliked Art Features: (.*)', generated_texts).groups()
353
  positive_vp = positive_vp.split(", ")
@@ -531,7 +529,8 @@ with gr.Blocks(css=css, title="ViPer Demo", theme=gr.themes.Base()) as demo:
531
  generator = torch.Generator().manual_seed(seed)
532
 
533
  if prompt is None:
534
- promtpt = ""
 
535
 
536
  image = pipe(prompt=prompt,
537
  num_inference_steps=num_inference_steps,
@@ -634,7 +633,7 @@ with gr.Blocks(css=css, title="ViPer Demo", theme=gr.themes.Base()) as demo:
634
  """
635
  )
636
 
637
- gr.Markdown("Please write your comments on the images below, explaining why you like or dislike each one from an artistic perspective. Focus on images that evoke **strong reactions**, whether positive or negative, and skip those that don't affect you much.\nMore **detailed** comments will help us provide more personalized results. We recommend commenting on **at least 8** images. If none of the provided images interest you, you can **upload** your own images.")
638
 
639
 
640
  with gr.Accordion("Examples of Effective Comments", open=False):
 
303
  if len(comments) < 8:
304
  gr.Warning("Fewer than 8 comments may lead to errors.")
305
 
306
+ keys = list(comments.keys())
307
+ random.shuffle(keys)
308
+ comments = dict([(key, comments[key]) for key in keys])
309
 
310
  prompt = """I will provide a set of artworks along with accompanying comments from a person. Analyze these artworks and the comments on them and identify artistic features such as present or mentioned colors, style, composition, mood, medium, texture, brushwork, lighting, shadow effects, perspective, and other noteworthy elements.
311
  Your task is to extract the artistic features the person likes and dislikes based on both the artworks' features and the person's comments. Focus solely on artistic aspects and refrain from considering subject matter.
 
346
  generated_ids = vpe_model.generate(**inputs, max_new_tokens=2000, repetition_penalty=0.99, do_sample=False)
347
  generated_texts = processor.batch_decode(generated_ids, skip_special_tokens=True)[0]
348
 
 
 
349
  if re.match(r"(.|\n)*Assistant: Liked Art Features: (.|\n)*Disliked Art Features: (.|\n)*", generated_texts):
350
  positive_vp, negative_vp = re.search('.* \nAssistant: Liked Art Features: (.*)\nDisliked Art Features: (.*)', generated_texts).groups()
351
  positive_vp = positive_vp.split(", ")
 
529
  generator = torch.Generator().manual_seed(seed)
530
 
531
  if prompt is None:
532
+ gr.Warning("Prompt is empty: a random image will be generated.")
533
+ prompt = ""
534
 
535
  image = pipe(prompt=prompt,
536
  num_inference_steps=num_inference_steps,
 
633
  """
634
  )
635
 
636
+ gr.Markdown("Please write your comments on the images below, explaining why you like or dislike each one from an artistic perspective. Comment on a mix of images: some that you like and some that you dislike. Focus on images that evoke strong reactions, whether positive or negative, and skip those that don't affect you much. More detailed comments will help us provide more personalized results. We recommend commenting on at least 8 images. If none of the provided images interest you, you can upload your own images.")
637
 
638
 
639
  with gr.Accordion("Examples of Effective Comments", open=False):