File size: 1,106 Bytes
b1fd6cc
f660379
 
b1fd6cc
ae30d65
 
 
 
 
f660379
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
import gradio as gr
from transformers import AutoProcessor, AutoModelForCausalLM
import torch

# Hugging Face tokeninizi çevresel değişkenden alın
hf_token = os.getenv("HF_TOKEN")
if not hf_token:
    raise ValueError("HF_TOKEN çevresel değişkeni ayarlanmamış. Lütfen Hugging Face token'ınızı ayarlayın.")

# Model ve işlemciyi yükleyin
model_name = "meta-llama/Llama-3.2-90B-Vision-Instruct"
processor = AutoProcessor.from_pretrained(model_name)
model = AutoModelForCausalLM.from_pretrained(model_name)

def predict(image, text):
    # Girdileri işleyin
    inputs = processor(images=image, text=text, return_tensors="pt")
    # Modelden yanıt alın
    outputs = model.generate(**inputs)
    # Çıktıyı çözümleyin
    response = processor.decode(outputs[0], skip_special_tokens=True)
    return response

# Gradio arayüzünü tanımlayın
interface = gr.Interface(
    fn=predict,
    inputs=["image", "text"],
    outputs="text",
    title="Llama 3.2 90B Vision Instruct Demo",
    description="Bir görüntü ve metin girdisi alarak yanıt üreten model."
)

interface.launch()