Spaces:
Sleeping
Sleeping
Update app.py
Browse files4 unmodified lines5678910118 unmodified lines20212223242526272829303132334 unmodified linesimport torchimport spacesdevice = "cuda" if torch.cuda.is_available() else "cpu" # Check if CUDA is availableMAX_SEED = np.iinfo(np.int32).maxMAX_IMAGE_SIZE = 10248 unmodified lines# Initialize the generator with the seedgenerator = torch.Generator(device=device).manual_seed(seed) # Ensure generator is on the correct device# Load the diffusion pipeline with float32 precision (avoiding issues with fp16)print("Loading model...")pipe = DiffusionPipeline.from_pretrained("stabilityai/sdxl-turbo", use_safetensors=True)pipe.enable_xformers_memory_efficient_attention()pipe = pipe.to(device) # Move the model to the GPU (or CPU if no GPU available)print("Model loaded successfully.")# Generate the imageprint(f"Generating image with prompt: {prompt}")image = pipe(4 unmodified lines5678910118 unmodified lines20212223242526272829303132334 unmodified linesimport torchimport spacesdevice = "cuda" if torch.cuda.is_available() else "cpu" # Check if CUDA is available, fallback to CPU if notMAX_SEED = np.iinfo(np.int32).maxMAX_IMAGE_SIZE = 10248 unmodified lines# Initialize the generator with the seedgenerator = torch.Generator(device=device).manual_seed(seed) # Ensure generator is on the correct device# Load a simpler model (e.g., "CompVis/stable-diffusion-v1-4" model, works well and is commonly used)print("Loading model...")pipe = DiffusionPipeline.from_pretrained("CompVis/stable-diffusion-v1-4", torch_dtype=torch.float32)pipe.enable_xformers_memory_efficient_attention()pipe = pipe.to(device) # Move the model to the correct device (GPU or CPU)print(f"Model loaded successfully on {device}.")# Generate the imageprint(f"Generating image with prompt: {prompt}")image = pipe(
app.py+6-6