Spaces:
Build error
Build error
Ketengan-Diffusion-Lab
commited on
Commit
•
b1bbde3
1
Parent(s):
9aeab55
Update app.py
Browse files
app.py
CHANGED
@@ -14,7 +14,7 @@ warnings.filterwarnings('ignore')
|
|
14 |
device = torch.device("cuda" if torch.cuda.is_available() else "cpu")
|
15 |
print(f"Using device: {device}")
|
16 |
|
17 |
-
model_name = 'cognitivecomputations/dolphin-vision-
|
18 |
|
19 |
# create model and load it to the specified device
|
20 |
model = AutoModelForCausalLM.from_pretrained(
|
@@ -29,8 +29,9 @@ tokenizer = AutoTokenizer.from_pretrained(
|
|
29 |
trust_remote_code=True
|
30 |
)
|
31 |
|
32 |
-
def inference(prompt, image, temperature, beam_size):
|
33 |
messages = [
|
|
|
34 |
{"role": "user", "content": f'<image>\n{prompt}'}
|
35 |
]
|
36 |
text = tokenizer.apply_chat_template(
|
@@ -65,6 +66,11 @@ def inference(prompt, image, temperature, beam_size):
|
|
65 |
with gr.Blocks() as demo:
|
66 |
with gr.Row():
|
67 |
with gr.Column():
|
|
|
|
|
|
|
|
|
|
|
68 |
prompt_input = gr.Textbox(label="Prompt", placeholder="Describe this image in detail")
|
69 |
image_input = gr.Image(label="Image", type="pil")
|
70 |
temperature_input = gr.Slider(minimum=0.1, maximum=2.0, value=0.7, step=0.1, label="Temperature")
|
@@ -75,7 +81,7 @@ with gr.Blocks() as demo:
|
|
75 |
|
76 |
submit_button.click(
|
77 |
fn=inference,
|
78 |
-
inputs=[prompt_input, image_input, temperature_input, beam_size_input],
|
79 |
outputs=output_text
|
80 |
)
|
81 |
|
|
|
14 |
device = torch.device("cuda" if torch.cuda.is_available() else "cpu")
|
15 |
print(f"Using device: {device}")
|
16 |
|
17 |
+
model_name = 'cognitivecomputations/dolphin-vision-7b'
|
18 |
|
19 |
# create model and load it to the specified device
|
20 |
model = AutoModelForCausalLM.from_pretrained(
|
|
|
29 |
trust_remote_code=True
|
30 |
)
|
31 |
|
32 |
+
def inference(prompt, image, temperature, beam_size, system_instruction):
|
33 |
messages = [
|
34 |
+
{"role": "system", "content": system_instruction},
|
35 |
{"role": "user", "content": f'<image>\n{prompt}'}
|
36 |
]
|
37 |
text = tokenizer.apply_chat_template(
|
|
|
66 |
with gr.Blocks() as demo:
|
67 |
with gr.Row():
|
68 |
with gr.Column():
|
69 |
+
system_instruction = gr.Textbox(
|
70 |
+
label="System Instruction",
|
71 |
+
value="You are Dolphin, a helpful AI assistant",
|
72 |
+
lines=2
|
73 |
+
)
|
74 |
prompt_input = gr.Textbox(label="Prompt", placeholder="Describe this image in detail")
|
75 |
image_input = gr.Image(label="Image", type="pil")
|
76 |
temperature_input = gr.Slider(minimum=0.1, maximum=2.0, value=0.7, step=0.1, label="Temperature")
|
|
|
81 |
|
82 |
submit_button.click(
|
83 |
fn=inference,
|
84 |
+
inputs=[prompt_input, image_input, temperature_input, beam_size_input, system_instruction],
|
85 |
outputs=output_text
|
86 |
)
|
87 |
|