Ali-C137 commited on
Commit
1b093cd
1 Parent(s): 7678417

Update app_dialogue.py

Browse files
Files changed (1) hide show
  1. app_dialogue.py +14 -89
app_dialogue.py CHANGED
@@ -30,14 +30,17 @@ DEVICE = torch.device("cuda")
30
  MODELS = {
31
  "idefics2-8b-chatty": Idefics2ForConditionalGeneration.from_pretrained(
32
  "HuggingFaceM4/idefics2-8b-chatty",
 
33
  torch_dtype=torch.bfloat16,
34
  _attn_implementation="flash_attention_2",
35
  ).to(DEVICE),
36
  }
37
  PROCESSOR = AutoProcessor.from_pretrained(
38
  "HuggingFaceM4/idefics2-8b",
 
39
  )
40
 
 
41
  SYSTEM_PROMPT = [
42
  {
43
  "role": "system",
@@ -84,89 +87,10 @@ EXAMPLES = [
84
  "files": [f"{examples_path}/example_images/paper_with_text.png"],
85
  }
86
  ],
87
- [
88
- {
89
- "text": "The respective main characters of these two movies meet in real life. Imagine their discussion. It should be sassy, and the beginning of a mysterious adventure.",
90
- "files": [f"{examples_path}/example_images/barbie.jpeg", f"{examples_path}/example_images/oppenheimer.jpeg"],
91
- }
92
- ],
93
- [
94
- {
95
- "text": "Can you explain this meme?",
96
- "files": [f"{examples_path}/example_images/running_girl_meme.webp"],
97
- }
98
- ],
99
- [
100
- {
101
- "text": "What happens to fish if pelicans increase?",
102
- "files": [f"{examples_path}/example_images/ai2d_example_2.jpeg"],
103
- }
104
- ],
105
- [
106
- {
107
- "text": "Give an art-critic description of this well known painting",
108
- "files": [f"{examples_path}/example_images/Van-Gogh-Starry-Night.jpg"],
109
- }
110
- ],
111
- [
112
- {
113
- "text": "Chase wants to buy 4 kilograms of oval beads and 5 kilograms of star-shaped beads. How much will he spend?",
114
- "files": [f"{examples_path}/example_images/mmmu_example.jpeg"],
115
- }
116
- ],
117
- [
118
- {
119
- "text": "Write an online ad for that product.",
120
- "files": [f"{examples_path}/example_images/shampoo.jpg"],
121
- }
122
- ],
123
- [
124
- {
125
- "text": "Describe this image in detail and explain why it is disturbing.",
126
- "files": [f"{examples_path}/example_images/cat_cloud.jpeg"],
127
- }
128
- ],
129
- [
130
- {
131
- "text": "Why is this image cute?",
132
- "files": [
133
- f"{examples_path}/example_images/kittens-cats-pet-cute-preview.jpg"
134
- ],
135
- }
136
- ],
137
- [
138
- {
139
- "text": "What is formed by the deposition of either the weathered remains of other rocks?",
140
- "files": [f"{examples_path}/example_images/ai2d_example.jpeg"],
141
- }
142
- ],
143
- [
144
- {
145
- "text": "What's funny about this image?",
146
- "files": [f"{examples_path}/example_images/pope_doudoune.webp"],
147
- }
148
- ],
149
- [
150
- {
151
- "text": "Can this happen in real life?",
152
- "files": [f"{examples_path}/example_images/elephant_spider_web.webp"],
153
- }
154
- ],
155
- [
156
- {
157
- "text": "What's unusual about this image?",
158
- "files": [f"{examples_path}/example_images/dragons_playing.png"],
159
- }
160
- ],
161
- [
162
- {
163
- "text": "Why is that image comical?",
164
- "files": [f"{examples_path}/example_images/eye_glasses.jpeg"],
165
- }
166
- ],
167
  ]
168
 
169
  BOT_AVATAR = "IDEFICS_logo.png"
 
170
 
171
 
172
  # Chatbot utils
@@ -265,6 +189,7 @@ def extract_images_from_msg_list(msg_list):
265
  return all_images
266
 
267
 
 
268
  @spaces.GPU(duration=180)
269
  def model_inference(
270
  user_prompt,
@@ -419,15 +344,15 @@ chatbot = gr.Chatbot(
419
  height=450,
420
  )
421
 
422
- with gr.Blocks(
423
- fill_height=True,
424
- css=""".gradio-container .avatar-container {height: 40px width: 40px !important;} #duplicate-button {margin: auto; color: white; background: #f1a139; border-radius: 100vh; margin-top: 2px; margin-bottom: 2px;}""",
425
- ) as demo:
426
-
427
- gr.Markdown("# 🐶 Hugging Face Idefics2 8B Chatty")
428
- gr.Markdown("In this demo you'll be able to chat with [Idefics2-8B-chatty](https://huggingface.co/HuggingFaceM4/idefics2-8b-chatty), a variant of [Idefics2-8B](https://huggingface.co/HuggingFaceM4/idefics2-8b-chatty) further fine-tuned on chat datasets.")
429
- gr.Markdown("If you want to learn more about Idefics2 and its variants, you can check our [blog post](https://huggingface.co/blog/idefics2).")
430
- gr.DuplicateButton(value="Duplicate Space for private use", elem_id="duplicate-button")
431
  # model selector should be set to `visbile=False` ultimately
432
  with gr.Row(elem_id="model_selector_row"):
433
  model_selector = gr.Dropdown(
 
30
  MODELS = {
31
  "idefics2-8b-chatty": Idefics2ForConditionalGeneration.from_pretrained(
32
  "HuggingFaceM4/idefics2-8b-chatty",
33
+ # "Ali-C137/idefics2-8b-chatty-yalla",
34
  torch_dtype=torch.bfloat16,
35
  _attn_implementation="flash_attention_2",
36
  ).to(DEVICE),
37
  }
38
  PROCESSOR = AutoProcessor.from_pretrained(
39
  "HuggingFaceM4/idefics2-8b",
40
+ # "Ali-C137/idefics2-8b-chatty-yalla",
41
  )
42
 
43
+ # Should change this section for the finetuned model
44
  SYSTEM_PROMPT = [
45
  {
46
  "role": "system",
 
87
  "files": [f"{examples_path}/example_images/paper_with_text.png"],
88
  }
89
  ],
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
90
  ]
91
 
92
  BOT_AVATAR = "IDEFICS_logo.png"
93
+ # BOT_AVATAR = "YALLA_logo.png"
94
 
95
 
96
  # Chatbot utils
 
189
  return all_images
190
 
191
 
192
+ # comment this call of spaces.GPU later
193
  @spaces.GPU(duration=180)
194
  def model_inference(
195
  user_prompt,
 
344
  height=450,
345
  )
346
 
347
+ # with gr.Blocks(
348
+ # fill_height=True, # Use this below !?
349
+ # css=""".gradio-container .avatar-container {height: 40px width: 40px !important;} #duplicate-button {margin: auto; color: white; background: #f1a139; border-radius: 100vh; margin-top: 2px; margin-bottom: 2px;}""",
350
+ # ) as demo:
351
+ with gr.Blocks() as demo:
352
+ gr.Markdown("# 🐶 YALLA ")
353
+ gr.Markdown("In this demo you'll be able to chat with YALLA, a variant of [Idefics2-8B](https://huggingface.co/HuggingFaceM4/idefics2-8b-chatty) further fine-tuned on chat datasets, and Moroccan culture 🇲🇦")
354
+ # gr.Markdown("If you want to learn more about Idefics2 and its variants, you can check our [blog post](https://huggingface.co/blog/idefics2).")
355
+ # gr.DuplicateButton(value="Duplicate Space for private use", elem_id="duplicate-button")
356
  # model selector should be set to `visbile=False` ultimately
357
  with gr.Row(elem_id="model_selector_row"):
358
  model_selector = gr.Dropdown(