prithivMLmods commited on
Commit
cb06874
1 Parent(s): 06274a0

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +6 -27
app.py CHANGED
@@ -2,10 +2,7 @@ import gradio as gr
2
  import spaces
3
  import numpy as np
4
  import random
5
- from diffusers import (
6
- DiffusionPipeline, AutoencoderTiny, AutoencoderKL,
7
- AutoPipelineForImage2Image, FluxPipeline, FlowMatchEulerDiscreteScheduler
8
- )
9
  import torch
10
  from PIL import Image
11
 
@@ -14,29 +11,14 @@ model_repo_id = "stabilityai/stable-diffusion-3.5-large-turbo"
14
 
15
  torch_dtype = torch.bfloat16 if torch.cuda.is_available() else torch.float32
16
 
17
- # Load primary diffusion model and assign a smaller VAE for faster real-time previewing
18
- taef1 = AutoencoderTiny.from_pretrained("madebyollin/taef1", torch_dtype=torch_dtype).to(device)
19
- good_vae = AutoencoderKL.from_pretrained(model_repo_id, subfolder="vae", torch_dtype=torch_dtype).to(device)
20
- pipe = DiffusionPipeline.from_pretrained(model_repo_id, torch_dtype=torch_dtype, vae=taef1).to(device)
21
-
22
- # Set up for image-to-image pipeline with good VAE and smaller encoder for efficient preview
23
- pipe_i2i = AutoPipelineForImage2Image.from_pretrained(
24
- model_repo_id,
25
- vae=good_vae,
26
- transformer=pipe.transformer,
27
- text_encoder=pipe.text_encoder,
28
- tokenizer=pipe.tokenizer,
29
- text_encoder_2=pipe.text_encoder_2,
30
- tokenizer_2=pipe.tokenizer_2,
31
- torch_dtype=torch_dtype
32
- )
33
-
34
- # Load LoRA weights and set the scale for "hyper-realistic" prompt style
35
  pipe.load_lora_weights("prithivMLmods/SD3.5-Large-Turbo-HyperRealistic-LoRA", weight_name="SD3.5-4Step-Large-Turbo-HyperRealistic-LoRA.safetensors")
36
- trigger_word = "hyper realistic"
37
  pipe.fuse_lora(lora_scale=1.0)
38
 
39
- MAX_SEED = 2**32 - 1
40
  MAX_IMAGE_SIZE = 1024
41
 
42
  # Define styles
@@ -122,9 +104,6 @@ def infer(
122
 
123
  return grid_img, seed
124
 
125
- # Setup for real-time image generation
126
- pipe.flux_pipe_call_that_returns_an_iterable_of_images = pipe.flux_pipe_call_that_returns_an_iterable_of_images.__get__(pipe)
127
-
128
  examples = [
129
  "A tiny astronaut hatching from an egg on the moon, 4k, planet theme",
130
  "An anime illustration of a wiener schnitzel --style raw5, 4K",
 
2
  import spaces
3
  import numpy as np
4
  import random
5
+ from diffusers import DiffusionPipeline
 
 
 
6
  import torch
7
  from PIL import Image
8
 
 
11
 
12
  torch_dtype = torch.bfloat16 if torch.cuda.is_available() else torch.float32
13
 
14
+ pipe = DiffusionPipeline.from_pretrained(model_repo_id, torch_dtype=torch_dtype)
15
+ pipe = pipe.to(device)
16
+
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
17
  pipe.load_lora_weights("prithivMLmods/SD3.5-Large-Turbo-HyperRealistic-LoRA", weight_name="SD3.5-4Step-Large-Turbo-HyperRealistic-LoRA.safetensors")
18
+ trigger_word = "hyper realistic" # Specify trigger word for LoRA
19
  pipe.fuse_lora(lora_scale=1.0)
20
 
21
+ MAX_SEED = np.iinfo(np.int32).max
22
  MAX_IMAGE_SIZE = 1024
23
 
24
  # Define styles
 
104
 
105
  return grid_img, seed
106
 
 
 
 
107
  examples = [
108
  "A tiny astronaut hatching from an egg on the moon, 4k, planet theme",
109
  "An anime illustration of a wiener schnitzel --style raw5, 4K",