dwb2023 commited on
Commit
ea72a36
·
verified ·
1 Parent(s): 7678417

update for salesforce xgen

Browse files
Files changed (1) hide show
  1. app_dialogue.py +10 -11
app_dialogue.py CHANGED
@@ -22,20 +22,20 @@ import io
22
  import datasets
23
 
24
  import gradio as gr
25
- from transformers import AutoProcessor, TextIteratorStreamer
26
- from transformers import Idefics2ForConditionalGeneration
27
 
28
 
29
  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 = [
@@ -44,7 +44,7 @@ SYSTEM_PROMPT = [
44
  "content": [
45
  {
46
  "type": "text",
47
- "text": "The following is a conversation between Idefics2, a highly knowledgeable and intelligent visual AI assistant created by Hugging Face, referred to as Assistant, and a human user called User. In the following interactions, User and Assistant will converse in natural language, and Assistant will do its best to answer User’s questions. Assistant has the ability to perceive images and reason about them, but it cannot generate images. Assistant was built to be respectful, polite and inclusive. It knows a lot, and always tells the truth. When prompted with an image, it does not make up facts.",
48
  },
49
  ],
50
  },
@@ -53,7 +53,7 @@ SYSTEM_PROMPT = [
53
  "content": [
54
  {
55
  "type": "text",
56
- "text": "Hello, I'm Idefics2, Huggingface's latest multimodal assistant. How can I help you?",
57
  },
58
  ],
59
  }
@@ -414,7 +414,7 @@ top_p = gr.Slider(
414
 
415
 
416
  chatbot = gr.Chatbot(
417
- label="Idefics2-Chatty",
418
  avatar_images=[None, BOT_AVATAR],
419
  height=450,
420
  )
@@ -424,9 +424,8 @@ with gr.Blocks(
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"):
 
22
  import datasets
23
 
24
  import gradio as gr
25
+ from transformers import AutoImageProcessor, TextIteratorStreamer
26
+ from transformers import AutoModelForVision2Seq
27
 
28
 
29
  DEVICE = torch.device("cuda")
30
  MODELS = {
31
+ "xgen-mm-phi3-mini-instruct-interleave-r-v1.5": AutoModelForVision2Seq.from_pretrained(
32
+ "Salesforce/xgen-mm-phi3-mini-instruct-interleave-r-v1.5",
33
  torch_dtype=torch.bfloat16,
34
  _attn_implementation="flash_attention_2",
35
  ).to(DEVICE),
36
  }
37
  PROCESSOR = AutoProcessor.from_pretrained(
38
+ "Salesforce/xgen-mm-phi3-mini-instruct-interleave-r-v1.5",
39
  )
40
 
41
  SYSTEM_PROMPT = [
 
44
  "content": [
45
  {
46
  "type": "text",
47
+ "text": "The following is a conversation between xgen-mm, a highly knowledgeable and intelligent visual AI assistant created by Salesforce, referred to as Assistant, and a human user called User. In the following interactions, User and Assistant will converse in natural language, and Assistant will do its best to answer User’s questions. Assistant has the ability to perceive images and reason about them, but it cannot generate images. Assistant was built to be respectful, polite and inclusive. It knows a lot, and always tells the truth. When prompted with an image, it does not make up facts.",
48
  },
49
  ],
50
  },
 
53
  "content": [
54
  {
55
  "type": "text",
56
+ "text": "Hello, I'm xgen-mm v1.5, Salesforce's latest multimodal assistant with interleave capabilities. How can I help you?",
57
  },
58
  ],
59
  }
 
414
 
415
 
416
  chatbot = gr.Chatbot(
417
+ label="xgen-mm-phi3-mini-instruct-interleave-r-v1.5",
418
  avatar_images=[None, BOT_AVATAR],
419
  height=450,
420
  )
 
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("# 🐶 Salesforce xgen-mm-phi3-mini-instruct-interleave-r-v1.5 ")
428
+ gr.Markdown("In this demo you'll be able to chat with [xgen-mm-phi3-mini-instruct-interleave-r-v1.5](https://huggingface.co/Salesforce/xgen-mm-phi3-mini-instruct-interleave-r-v1.5)")
 
429
  gr.DuplicateButton(value="Duplicate Space for private use", elem_id="duplicate-button")
430
  # model selector should be set to `visbile=False` ultimately
431
  with gr.Row(elem_id="model_selector_row"):