Spaces:
Running
on
Zero
Running
on
Zero
gokaygokay
commited on
Commit
•
6385c67
1
Parent(s):
90476a3
Create app.py
Browse files
app.py
ADDED
@@ -0,0 +1,42 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
from lmdeploy import pipeline
|
2 |
+
from lmdeploy.vl import load_image
|
3 |
+
|
4 |
+
pipe = pipeline('gokaygokay/llava-llama3-docci')
|
5 |
+
|
6 |
+
@spaces.GPU
|
7 |
+
def create_captions_llava_llama3_docci(image):
|
8 |
+
gen_config = GenerationConfig(repetition_penalty=1.10)
|
9 |
+
image = Image.fromarray(np.uint8(image)).convert('RGB')
|
10 |
+
response = pipe(('describe this image in detail', image), gen_config=gen_config)
|
11 |
+
return response.text
|
12 |
+
|
13 |
+
css = """
|
14 |
+
#mkd {
|
15 |
+
height: 500px;
|
16 |
+
overflow: auto;
|
17 |
+
border: 1px solid #ccc;
|
18 |
+
}
|
19 |
+
"""
|
20 |
+
|
21 |
+
with gr.Blocks(css=css) as demo:
|
22 |
+
gr.HTML("<h1><center>Fine tuned version of xtuner/llava-llama-3-8b-v1_1 on google/docci dataset.<center><h1>")
|
23 |
+
|
24 |
+
with gr.Tab(label="SD3 Llava Llama3 Captioner"):
|
25 |
+
with gr.Row():
|
26 |
+
with gr.Column():
|
27 |
+
input_img = gr.Image(label="Input Picture")
|
28 |
+
submit_btn = gr.Button(value="Submit")
|
29 |
+
output = gr.Text(label="Caption")
|
30 |
+
|
31 |
+
gr.Examples(
|
32 |
+
[["assets/image1.png"], ["assets/image2.PNG"], ["assets/image3.jpg"]],
|
33 |
+
inputs = [input_img],
|
34 |
+
outputs = [output],
|
35 |
+
fn=create_captions_llava_llama3_docci,
|
36 |
+
label='Try captioning on examples'
|
37 |
+
)
|
38 |
+
|
39 |
+
submit_btn.click(create_captions_llava_llama3_docci, [input_img], [output])
|
40 |
+
|
41 |
+
|
42 |
+
demo.launch(debug=True)
|