MaziyarPanahi commited on
Commit
bdaba80
1 Parent(s): 8330db2
Files changed (1) hide show
  1. app.py +3 -2
app.py CHANGED
@@ -1,7 +1,7 @@
1
  import gradio as gr
2
 
3
  from transformers import AutoProcessor, LlavaForConditionalGeneration
4
- from transformers import AutoModelForCausalLM, AutoTokenizer, TextStreamer
5
 
6
  from threading import Thread
7
  import re
@@ -38,6 +38,7 @@ def bot_streaming(message, history):
38
  if image is None:
39
  gr.Error("You need to upload an image for LLaVA to work.")
40
  prompt=f"<|start_header_id|>user<|end_header_id|>\n\n<image>\n{message['text']}<|eot_id|><|start_header_id|>assistant<|end_header_id|>\n\n"
 
41
  image = Image.open(image).convert("RGB")
42
  inputs = processor(prompt, image, return_tensors="pt").to("cuda:0")
43
 
@@ -49,7 +50,7 @@ def bot_streaming(message, history):
49
  thread.start()
50
 
51
  text_prompt =f"<|start_header_id|>user<|end_header_id|>\n\n{message['text']}<|eot_id|><|start_header_id|>assistant<|end_header_id|>\n\n"
52
-
53
 
54
  buffer = ""
55
  for new_text in streamer:
 
1
  import gradio as gr
2
 
3
  from transformers import AutoProcessor, LlavaForConditionalGeneration
4
+ from transformers import AutoModelForCausalLM, AutoTokenizer, TextStreamer, TextIteratorStreamer
5
 
6
  from threading import Thread
7
  import re
 
38
  if image is None:
39
  gr.Error("You need to upload an image for LLaVA to work.")
40
  prompt=f"<|start_header_id|>user<|end_header_id|>\n\n<image>\n{message['text']}<|eot_id|><|start_header_id|>assistant<|end_header_id|>\n\n"
41
+ print(f"prompt: {prompt}")
42
  image = Image.open(image).convert("RGB")
43
  inputs = processor(prompt, image, return_tensors="pt").to("cuda:0")
44
 
 
50
  thread.start()
51
 
52
  text_prompt =f"<|start_header_id|>user<|end_header_id|>\n\n{message['text']}<|eot_id|><|start_header_id|>assistant<|end_header_id|>\n\n"
53
+ print(f"text_prompt: {text_prompt}")
54
 
55
  buffer = ""
56
  for new_text in streamer: