BOUDELLAH commited on
Commit
e0776a4
1 Parent(s): 1c77e26

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +26 -0
app.py ADDED
@@ -0,0 +1,26 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+ from transformers import AutoModelForCausalLM, AutoTokenizer
3
+
4
+ # Load the model and tokenizer
5
+ model_name = "llava-hf/llava-v1.6-vicuna-13b-hf"
6
+ tokenizer = AutoTokenizer.from_pretrained(model_name)
7
+ model = AutoModelForCausalLM.from_pretrained(model_name)
8
+
9
+ def generate_response(input_text):
10
+ # Tokenize and generate
11
+ inputs = tokenizer(input_text, return_tensors="pt")
12
+ outputs = model.generate(**inputs, max_length=200)
13
+ response = tokenizer.decode(outputs[0], skip_special_tokens=True)
14
+ return response
15
+
16
+ # Create a Gradio interface
17
+ interface = gr.Interface(
18
+ fn=generate_response,
19
+ inputs="text",
20
+ outputs="text",
21
+ title="LLaVA-v1.6-vicuna-13b",
22
+ description="This is a chatbot interface for the llava-hf/llava-v1.6-vicuna-13b-hf model."
23
+ )
24
+
25
+ # Launch the interface
26
+ interface.launch()