Spaces:
Running
on
L40S
Running
on
L40S
Update app.py
Browse files
app.py
CHANGED
@@ -42,8 +42,8 @@ with gr.Blocks(css=css, title="ViPer Demo", theme=gr.themes.Base()) as demo:
|
|
42 |
device = "cuda" if torch.cuda.is_available() else "cpu"
|
43 |
|
44 |
|
45 |
-
|
46 |
-
|
47 |
|
48 |
bnb_config = BitsAndBytesConfig(
|
49 |
load_in_4bit=True,
|
@@ -255,8 +255,6 @@ with gr.Blocks(css=css, title="ViPer Demo", theme=gr.themes.Base()) as demo:
|
|
255 |
|
256 |
clear_botton = gr.Button("Clear comments", interactive=len(comments) != 0)
|
257 |
|
258 |
-
print(comments)
|
259 |
-
|
260 |
return (gr.Image(value=comment_images[0], label=f"image {image_index+1}/{len(comment_images)}", show_label=True),
|
261 |
gr.Text(label="Comment", show_label=False, lines=4, max_lines=5, placeholder="Enter your comment. The more detailed the better.", value=next_comment, container=False),
|
262 |
gr.Button(f"Extract visual preference from {len(comments)} comments", interactive=len(comments) >= 5, variant="primary"),
|
@@ -507,11 +505,11 @@ with gr.Blocks(css=css, title="ViPer Demo", theme=gr.themes.Base()) as demo:
|
|
507 |
if vp_pos == "" and vp_neg == "":
|
508 |
slider = 0
|
509 |
|
510 |
-
|
511 |
-
|
512 |
-
|
513 |
-
|
514 |
-
|
515 |
|
516 |
if vp_pos != "":
|
517 |
vp_pos = vp_pos.split(", ")
|
|
|
42 |
device = "cuda" if torch.cuda.is_available() else "cpu"
|
43 |
|
44 |
|
45 |
+
word_list_dataset = load_dataset("EPFL-VILAB/4m-wordlist", data_files="list.txt", use_auth_token=True)
|
46 |
+
word_list = word_list_dataset["train"]['text']
|
47 |
|
48 |
bnb_config = BitsAndBytesConfig(
|
49 |
load_in_4bit=True,
|
|
|
255 |
|
256 |
clear_botton = gr.Button("Clear comments", interactive=len(comments) != 0)
|
257 |
|
|
|
|
|
258 |
return (gr.Image(value=comment_images[0], label=f"image {image_index+1}/{len(comment_images)}", show_label=True),
|
259 |
gr.Text(label="Comment", show_label=False, lines=4, max_lines=5, placeholder="Enter your comment. The more detailed the better.", value=next_comment, container=False),
|
260 |
gr.Button(f"Extract visual preference from {len(comments)} comments", interactive=len(comments) >= 5, variant="primary"),
|
|
|
505 |
if vp_pos == "" and vp_neg == "":
|
506 |
slider = 0
|
507 |
|
508 |
+
for filter in word_list:
|
509 |
+
if re.search(rf"\b{filter}\b", prompt):
|
510 |
+
raise gr.Error("Please try again with a different prompt")
|
511 |
+
if re.search(rf"\b{filter}\b", vp_pos) or re.search(rf"\b{filter}\b", vp_neg):
|
512 |
+
raise gr.Error("Please try again with a different visual preference")
|
513 |
|
514 |
if vp_pos != "":
|
515 |
vp_pos = vp_pos.split(", ")
|