|
|
|
import gradio as gr |
|
from transformers import AutoModelForCausalLM, AutoTokenizer |
|
|
|
|
|
model_name = "SeanScripts/NVLM-D-72B-nf4" |
|
model = AutoModelForCausalLM.from_pretrained(model_name, trust_remote_code=True) |
|
tokenizer = AutoTokenizer.from_pretrained(model_name, trust_remote_code=True) |
|
|
|
|
|
def predict(text): |
|
|
|
inputs = tokenizer(text, return_tensors="pt") |
|
|
|
|
|
outputs = model.generate(**inputs) |
|
|
|
|
|
return tokenizer.decode(outputs[0], skip_special_tokens=True) |
|
|
|
|
|
iface = gr.Interface( |
|
fn=predict, |
|
inputs="text", |
|
outputs="text", |
|
title="Prédiction avec NVLM-D", |
|
description="Entrez un texte pour obtenir une prédiction avec le modèle NVLM-D." |
|
) |
|
|
|
|
|
iface.launch() |
|
|