Spaces:
Runtime error
Runtime error
File size: 2,076 Bytes
90aa8b9 d79bce7 8b228ab d79bce7 8b228ab d79bce7 8b228ab d79bce7 8b228ab d79bce7 8b228ab d79bce7 8b228ab d79bce7 8b228ab d79bce7 |
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 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 |
import gradio as gr
import torch
from diffusers import StableDiffusionPipeline
def image_generation(prompt):
device = "cuda" if torch.cuda.is_available() else "cpu"
pipeline = StableDiffusionPipeline.from_pretrained(
"stabilityai/stable-diffusion-3-medium",
torch_dtype=torch.float16 if device == "cuda" else torch.float32,
)
#pipeline.to(device)
pipeline.enable_model_cpu_offload()
image = pipeline(
prompt=prompt,
negative_prompt="blurred, ugly, watermark, low resolution, blurry, nude",
num_inference_steps=40,
height=1024,
width=1024,
guidance_scale=8.0
).images[0]
return image
interface = gr.Interface(
fn=image_generation,
inputs=gr.Textbox(lines=2, placeholder="Enter Your Prompt ..."),
outputs=gr.Image(type="pil"),
title="AI Text Generation By SD-3M"
)
interface.launch()
# import gradio as gr
# import torch
# from diffusers import StableDiffusers3Pipeline
# def image_generation(prompt):
# device = "cuda" if torch.cuda.is_available() else "cpu"
# pipeline = StableDiffusers3Pipeline.from_pretrained("stabilityai/stable-diffusion-3-medium-diffusers",
# torch_dtype=torch.float16 if device == "cuda" else torch.float32,
# text_encoder_3 = None,
# tokenizer_3 = None)
# # pipeline.to(device)
# pipeline.enable_model_cpu_offload()
# image = pipeline(
# prompt = prompt,
# negative_prompt = "blurred, ugly, watermark, low resolution, blurry, nude",
# num_inference_steps = 40,
# height=1024,
# width=1024,
# guidance_scale=8.0
# ).images[0]
# image.show()
# interface= gr.interface(
# fn=image_generation,
# inputs = gr.Textbox(lines="2", placeholder="Enter Your Prompt ..."),
# outputs = gr.Image(type="pil"),
# title = "AI Text Generation By SD-3M"
# )
# interface.launch() |