harmionestark commited on
Commit
58cedc4
Β·
verified Β·
1 Parent(s): f565096

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +7 -2
app.py CHANGED
@@ -6,8 +6,13 @@ app = Flask(__name__)
6
 
7
  # Load the model
8
  model_id = "ZB-Tech/Text-to-Image"
9
- pipeline = StableDiffusionPipeline.from_pretrained(model_id, torch_dtype=torch.float16)
10
- pipeline.to("cuda" if torch.cuda.is_available() else "cpu")
 
 
 
 
 
11
 
12
  @app.route("/generate", methods=["POST"])
13
  def generate_image():
 
6
 
7
  # Load the model
8
  model_id = "ZB-Tech/Text-to-Image"
9
+ device = "cuda" if torch.cuda.is_available() else "cpu"
10
+
11
+ # Use float32 if running on CPU
12
+ torch_dtype = torch.float16 if device == "cuda" else torch.float32
13
+
14
+ pipeline = StableDiffusionPipeline.from_pretrained(model_id, torch_dtype=torch_dtype)
15
+ pipeline.to(device)
16
 
17
  @app.route("/generate", methods=["POST"])
18
  def generate_image():