|
import torch |
|
import gradio as gr |
|
from fastapi import FastAPI |
|
|
|
|
|
import os |
|
from PIL import Image |
|
|
|
import tempfile |
|
from transformers import TextStreamer |
|
from utils import title_markdown |
|
from utils import block_css |
|
from utils import tos_markdown |
|
from utils import learn_more_markdown |
|
|
|
|
|
|
|
textbox = gr.Textbox( |
|
show_label = False, placeholder = "Enter text and press ENTER", container = False |
|
) |
|
|
|
with gr.Blocks(title = '' ) as demo: |
|
gr.Markdown(title_markdown) |
|
|
|
with gr.Blocks(title='MoE-LLaVA๐') as demo: |
|
gr.Markdown(title_markdown) |
|
state = gr.State() |
|
state_ = gr.State() |
|
first_run = gr.State() |
|
images_tensor = gr.State() |
|
|
|
with gr.Row(): |
|
with gr.Column(scale=3): |
|
image1 = gr.Image(label="Input Document", type="filepath") |
|
|
|
cur_dir = os.path.dirname(os.path.abspath(__file__)) |
|
print(cur_dir) |
|
gr.Examples( |
|
examples=[ |
|
[ "http://www.marketingtool.online/en/face-generator/img/faces/avatar-1151ce9f4b2043de0d2e3b7826127998.jpg", |
|
"What is unusual about this image?", |
|
], |
|
["http://www.marketingtool.online/en/face-generator/img/faces/avatar-1151ce9f4b2043de0d2e3b7826127998.jpg", |
|
"What are the things I should be cautious about when I visit here?", |
|
], |
|
["http://www.marketingtool.online/en/face-generator/img/faces/avatar-1151ce9f4b2043de0d2e3b7826127998.jpg", |
|
"If there are factual errors in the questions, point it out; if not, proceed answering the question. Whatโs happening in the desert?", |
|
], |
|
["http://www.marketingtool.online/en/face-generator/img/faces/avatar-1151ce9f4b2043de0d2e3b7826127998.jpg", |
|
"What is the title of this book?", |
|
], |
|
["http://www.marketingtool.online/en/face-generator/img/faces/avatar-1151ce9f4b2043de0d2e3b7826127998.jpg", |
|
"What type of food is the girl holding?", |
|
], |
|
["http://www.marketingtool.online/en/face-generator/img/faces/avatar-1151ce9f4b2043de0d2e3b7826127998.jpg", |
|
"What color is the train?", |
|
], |
|
["http://www.marketingtool.online/en/face-generator/img/faces/avatar-1151ce9f4b2043de0d2e3b7826127998.jpg", |
|
"What is the girl looking at?", |
|
], |
|
["http://www.marketingtool.online/en/face-generator/img/faces/avatar-1151ce9f4b2043de0d2e3b7826127998.jpg", |
|
"What might be the reason for the dog's aggressive behavior?", |
|
], |
|
], |
|
inputs=[image1, textbox], |
|
) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
demo.launch() |
|
|