Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
|
@@ -2,6 +2,7 @@ import gradio as gr
|
|
| 2 |
import torch
|
| 3 |
from diffusers import StableDiffusion3Pipeline
|
| 4 |
import os
|
|
|
|
| 5 |
|
| 6 |
# Retrieve the API token from the environment variable
|
| 7 |
huggingface_token = os.getenv("HUGGINGFACE_TOKEN")
|
|
@@ -11,9 +12,21 @@ if huggingface_token is None:
|
|
| 11 |
# Check if CUDA is available
|
| 12 |
device = "cuda" if torch.cuda.is_available() else "cpu"
|
| 13 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 14 |
# Load the Stable Diffusion model
|
| 15 |
repo = "stabilityai/stable-diffusion-3-medium-diffusers"
|
| 16 |
-
image_gen = StableDiffusion3Pipeline.from_pretrained(repo, text_encoder_3=None, tokenizer_3=None, use_auth_token=huggingface_token)
|
|
|
|
|
|
|
|
|
|
|
|
|
| 17 |
image_gen = image_gen.to(device)
|
| 18 |
|
| 19 |
def generate_image(prompt, num_inference_steps=50, guidance_scale=7.5):
|
|
|
|
| 2 |
import torch
|
| 3 |
from diffusers import StableDiffusion3Pipeline
|
| 4 |
import os
|
| 5 |
+
from huggingface_hub import snapshot_download
|
| 6 |
|
| 7 |
# Retrieve the API token from the environment variable
|
| 8 |
huggingface_token = os.getenv("HUGGINGFACE_TOKEN")
|
|
|
|
| 12 |
# Check if CUDA is available
|
| 13 |
device = "cuda" if torch.cuda.is_available() else "cpu"
|
| 14 |
|
| 15 |
+
model_path = snapshot_download(
|
| 16 |
+
repo_id="stabilityai/stable-diffusion-3-medium",
|
| 17 |
+
revision="refs/pr/26",
|
| 18 |
+
repo_type="model",
|
| 19 |
+
ignore_patterns=["*.md", "*..gitattributes"],
|
| 20 |
+
local_dir="stable-diffusion-3-medium",
|
| 21 |
+
token=huggingface_token, # yeni bir token-id yazın.
|
| 22 |
+
)
|
| 23 |
# Load the Stable Diffusion model
|
| 24 |
repo = "stabilityai/stable-diffusion-3-medium-diffusers"
|
| 25 |
+
#image_gen = StableDiffusion3Pipeline.from_pretrained(repo, text_encoder_3=None, tokenizer_3=None, use_auth_token=huggingface_token)
|
| 26 |
+
image_gen = StableDiffusion3Pipeline.from_pretrained(repo, text_encoder_3=None, tokenizer_3=None)
|
| 27 |
+
|
| 28 |
+
#pipe = StableDiffusion3Pipeline.from_pretrained(model_path, torch_dtype=torch.float16)
|
| 29 |
+
|
| 30 |
image_gen = image_gen.to(device)
|
| 31 |
|
| 32 |
def generate_image(prompt, num_inference_steps=50, guidance_scale=7.5):
|