yeshog50 commited on
Commit
3cbcaed
·
verified ·
1 Parent(s): 20e4a25

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +7 -25
app.py CHANGED
@@ -2,42 +2,24 @@ import os
2
  import random
3
  import gradio as gr
4
  import torch
5
- from diffusers import DiffusionPipeline
6
  from transformers import CLIPTextModel, CLIPTokenizer
7
 
8
- # Configuration - Using Flux Model
9
- MODEL_ID = "CompVis/Flux-Pro"
10
  MODEL_CACHE = "model_cache"
11
  os.makedirs(MODEL_CACHE, exist_ok=True)
12
 
13
  def get_pipeline():
14
- # Load Flux model components
15
- text_encoder = CLIPTextModel.from_pretrained(
16
  MODEL_ID,
17
- subfolder="text_encoder",
18
- cache_dir=MODEL_CACHE
19
- )
20
-
21
- tokenizer = CLIPTokenizer.from_pretrained(
22
- MODEL_ID,
23
- subfolder="tokenizer",
24
- cache_dir=MODEL_CACHE
25
- )
26
-
27
- # Create pipeline
28
- pipe = DiffusionPipeline.from_pretrained(
29
- MODEL_ID,
30
- text_encoder=text_encoder,
31
- tokenizer=tokenizer,
32
- cache_dir=MODEL_CACHE,
33
  torch_dtype=torch.float32,
34
- safety_checker=None
 
 
35
  )
36
-
37
- # CPU optimizations
38
  pipe = pipe.to("cpu")
39
  pipe.enable_attention_slicing()
40
-
41
  return pipe
42
 
43
  # Load model
 
2
  import random
3
  import gradio as gr
4
  import torch
5
+ from diffusers import StableDiffusionPipeline # Changed import
6
  from transformers import CLIPTextModel, CLIPTokenizer
7
 
8
+ # Configuration
9
+ MODEL_ID = "CompVis/stable-diffusion-v1-4" # Changed to working model
10
  MODEL_CACHE = "model_cache"
11
  os.makedirs(MODEL_CACHE, exist_ok=True)
12
 
13
  def get_pipeline():
14
+ pipe = StableDiffusionPipeline.from_pretrained(
 
15
  MODEL_ID,
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
16
  torch_dtype=torch.float32,
17
+ cache_dir=MODEL_CACHE,
18
+ safety_checker=None,
19
+ use_safetensors=True
20
  )
 
 
21
  pipe = pipe.to("cpu")
22
  pipe.enable_attention_slicing()
 
23
  return pipe
24
 
25
  # Load model