gemma_2b / app.py
bk939448's picture
Update app.py
2d8fea2 verified
raw
history blame contribute delete
532 Bytes
import os
from huggingface_hub import login
from transformers import pipeline
import gradio as gr
# πŸ” Login using the secret token (set in Space Settings > Secrets)
login(os.getenv("HF_TOKEN"))
# πŸš€ Load the gated model
pipe = pipeline("text-generation", model="google/gemma-2b-it")
# 🧠 Generation function
def generate(prompt):
output = pipe(prompt, max_new_tokens=100)
return output[0]["generated_text"]
# πŸŽ›οΈ Gradio Interface
iface = gr.Interface(fn=generate, inputs="text", outputs="text")
iface.launch()