HarshanaLF commited on
Commit
a0f5ef3
1 Parent(s): ecb6f93
Files changed (1) hide show
  1. app.py +6 -6
app.py CHANGED
@@ -27,22 +27,22 @@ model.to("cpu")
27
 
28
 
29
  def llava(message, history):
30
- if hasattr(message, 'files') and message.files:
31
- image = message.files[0]
32
  else:
33
  for hist in history:
34
- if isinstance(hist[0], tuple):
35
  image = hist[0][0]
36
 
37
- txt = message.text # Assuming 'text' is an attribute
 
38
  gr.Info("Analyzing image")
39
  image = Image.open(image).convert("RGB")
40
- prompt = f"user <image>\n{txt}assistant"
41
 
42
  inputs = processor(prompt, image, return_tensors="pt")
43
  return inputs
44
 
45
-
46
  def extract_text_from_webpage(html_content):
47
  soup = BeautifulSoup(html_content, 'html.parser')
48
  for tag in soup(["script", "style", "header", "footer"]):
 
27
 
28
 
29
  def llava(message, history):
30
+ if message["files"]:
31
+ image = message["files"][0]
32
  else:
33
  for hist in history:
34
+ if type(hist[0])==tuple:
35
  image = hist[0][0]
36
 
37
+ txt = message["text"]
38
+
39
  gr.Info("Analyzing image")
40
  image = Image.open(image).convert("RGB")
41
+ prompt = f"<|im_start|>user <image>\n{txt}<|im_end|><|im_start|>assistant"
42
 
43
  inputs = processor(prompt, image, return_tensors="pt")
44
  return inputs
45
 
 
46
  def extract_text_from_webpage(html_content):
47
  soup = BeautifulSoup(html_content, 'html.parser')
48
  for tag in soup(["script", "style", "header", "footer"]):