yash1161's picture
Made some changes
0b90440
raw
history blame contribute delete
890 Bytes
import os
from huggingface_hub import login
import gradio as gr
# Load Hugging Face API Token from Secrets (Hugging Face Spaces Secrets or Environment Variables)
HF_TOKEN = os.getenv("HF_TOKEN")
# Authenticate with Hugging Face
if HF_TOKEN:
login(token=HF_TOKEN)
else:
raise ValueError("❌ Hugging Face Token Not Found. Please set HF_TOKEN in Secrets.")
# Load Stable Diffusion Model from Hugging Face Hub
model = gr.load("models/prithivMLmods/SD3.5-Turbo-Realism-2.0-LoRA")
# Define Gradio Interface
def generate_image(prompt: str):
return model(prompt)
demo = gr.Interface(
fn=generate_image,
inputs=gr.Textbox(label="Enter a Prompt"),
outputs="image",
title="Stable Diffusion Image Generator",
description="Generate images from text using Stable Diffusion 3.5 Turbo Realism LoRA."
)
# Launch Gradio App
if __name__ == "__main__":
demo.launch()