Update app.py
Browse files
app.py
CHANGED
@@ -4,6 +4,7 @@ import warnings
|
|
4 |
import os
|
5 |
import shutil
|
6 |
import subprocess
|
|
|
7 |
import torch
|
8 |
import numpy as np
|
9 |
from diffusers import FluxControlNetModel
|
@@ -95,6 +96,8 @@ logger.info("Pipeline loaded successfully.")
|
|
95 |
MAX_SEED = 1000000
|
96 |
MAX_PIXEL_BUDGET = 1024 * 1024
|
97 |
|
|
|
|
|
98 |
def process_input(input_image, upscale_factor):
|
99 |
w, h = input_image.size
|
100 |
aspect_ratio = w / h
|
@@ -118,6 +121,7 @@ def process_input(input_image, upscale_factor):
|
|
118 |
|
119 |
return input_image.resize((w, h)), was_resized
|
120 |
|
|
|
121 |
def run_inference(process_id, input_image, upscale_factor, seed, num_inference_steps, controlnet_conditioning_scale):
|
122 |
logger.info("Processing inference for process_id: %s", process_id)
|
123 |
input_image, was_resized = process_input(input_image, upscale_factor)
|
@@ -157,6 +161,7 @@ def run_inference(process_id, input_image, upscale_factor, seed, num_inference_s
|
|
157 |
logger.info("Inference completed for process_id: %s", process_id)
|
158 |
|
159 |
@app.route('/infer', methods=['POST'])
|
|
|
160 |
def infer():
|
161 |
# Check if the file was provided in the form-data
|
162 |
if 'input_image' not in request.files:
|
@@ -213,6 +218,7 @@ def infer():
|
|
213 |
|
214 |
# Modify status endpoint to receive process_id in request body
|
215 |
@app.route('/status', methods=['POST'])
|
|
|
216 |
def status():
|
217 |
data = request.json
|
218 |
process_id = data.get('process_id')
|
|
|
4 |
import os
|
5 |
import shutil
|
6 |
import subprocess
|
7 |
+
import spaces
|
8 |
import torch
|
9 |
import numpy as np
|
10 |
from diffusers import FluxControlNetModel
|
|
|
96 |
MAX_SEED = 1000000
|
97 |
MAX_PIXEL_BUDGET = 1024 * 1024
|
98 |
|
99 |
+
|
100 |
+
@spaces.GPU
|
101 |
def process_input(input_image, upscale_factor):
|
102 |
w, h = input_image.size
|
103 |
aspect_ratio = w / h
|
|
|
121 |
|
122 |
return input_image.resize((w, h)), was_resized
|
123 |
|
124 |
+
@spaces.GPU
|
125 |
def run_inference(process_id, input_image, upscale_factor, seed, num_inference_steps, controlnet_conditioning_scale):
|
126 |
logger.info("Processing inference for process_id: %s", process_id)
|
127 |
input_image, was_resized = process_input(input_image, upscale_factor)
|
|
|
161 |
logger.info("Inference completed for process_id: %s", process_id)
|
162 |
|
163 |
@app.route('/infer', methods=['POST'])
|
164 |
+
@spaces.GPU
|
165 |
def infer():
|
166 |
# Check if the file was provided in the form-data
|
167 |
if 'input_image' not in request.files:
|
|
|
218 |
|
219 |
# Modify status endpoint to receive process_id in request body
|
220 |
@app.route('/status', methods=['POST'])
|
221 |
+
@spaces.GPU
|
222 |
def status():
|
223 |
data = request.json
|
224 |
process_id = data.get('process_id')
|