Fetching metadata from the HF Docker repository...
-
Update app.py
import gradio as gr
import torch
from transformers import AutoProcessor, AutoModelForCausalLM
from PIL import Image
import os
model_id = "wisdomik/Quilt-Llava-v1.5-7b"
device = "cuda" if torch.cuda.is_available() else "cpu"
processor = AutoProcessor.from_pretrained(model_id)
model = AutoModelForCausalLM.from_pretrained(
model_id,
torch_dtype=torch.float16,
load_in_4bit=True,
device_map="auto"
)
def predict(image, message, history):
if image is not None:
prompt = f"USER: <image>\n{message} ASSISTANT:"
else:
prompt = f"USER: {message} ASSISTANT:"
inputs = processor(prompt, images=image, return_tensors="pt").to(device)
with torch.no_grad():
output = model.generate(**inputs, max_new_tokens=512, temperature=0.7)
response = processor.decode(output[0], skip_special_tokens=True)
response = response.split("ASSISTANT:")[-1].strip()
history.append((message, response))
return history, ""
with gr.Blocks(title="Quilt-LLaV… -
Create requirements.txt
-
Create app.py
-
Upload app.py.txt
-
initial commit