soiz commited on
Commit
c23c889
·
verified ·
1 Parent(s): e71ff7b

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +18 -4
app.py CHANGED
@@ -15,7 +15,7 @@ headers = {"Authorization": f"Bearer {API_TOKEN}"}
15
  timeout = 50000 # タイムアウトを300秒に設定
16
 
17
  # Function to query the API and return the generated image
18
- def query(prompt, negative_prompt="", steps=35, cfg_scale=7, sampler="DPM++ 2M Karras", seed=-1, strength=0.7, width=1024, height=1024):
19
  if not prompt:
20
  return None, "Prompt is required"
21
 
@@ -39,7 +39,14 @@ def query(prompt, negative_prompt="", steps=35, cfg_scale=7, sampler="DPM++ 2M K
39
  "negative_prompt": negative_prompt,
40
  "parameters": {
41
  "width": width,
42
- "height": height
 
 
 
 
 
 
 
43
  }
44
  }
45
 
@@ -99,8 +106,15 @@ def generate_image():
99
  seed = int(request.args.get("seed", -1))
100
  width = int(request.args.get("width", 1024))
101
  height = int(request.args.get("height", 1024))
102
-
103
- image, error = query(prompt, negative_prompt, steps, cfg_scale, sampler, seed, strength, width, height)
 
 
 
 
 
 
 
104
 
105
  if error:
106
  return jsonify({"error": error}), 400
 
15
  timeout = 50000 # タイムアウトを300秒に設定
16
 
17
  # Function to query the API and return the generated image
18
+ def query(prompt, negative_prompt="", steps=35, cfg_scale=7, sampler="DPM++ 2M Karras", seed=-1, strength=0.7, width=1024, height=1024, num_inference_steps=30, guidance_scale=7.5, num_return_sequences=1, temperature=1.0, top_k=50, top_p=0.9, eta=0.1):
19
  if not prompt:
20
  return None, "Prompt is required"
21
 
 
39
  "negative_prompt": negative_prompt,
40
  "parameters": {
41
  "width": width,
42
+ "height": height,
43
+ "num_inference_steps": num_inference_steps,
44
+ "guidance_scale": guidance_scale,
45
+ "num_return_sequences": num_return_sequences,
46
+ "temperature": temperature,
47
+ "top_k": top_k,
48
+ "top_p": top_p,
49
+ "eta": eta
50
  }
51
  }
52
 
 
106
  seed = int(request.args.get("seed", -1))
107
  width = int(request.args.get("width", 1024))
108
  height = int(request.args.get("height", 1024))
109
+ num_inference_steps = int(request.args.get("num_inference_steps", 30))
110
+ guidance_scale = float(request.args.get("guidance_scale", 7.5))
111
+ num_return_sequences = int(request.args.get("num_return_sequences", 1))
112
+ temperature = float(request.args.get("temperature", 1.0))
113
+ top_k = int(request.args.get("top_k", 50))
114
+ top_p = float(request.args.get("top_p", 0.9))
115
+ eta = float(request.args.get("eta", 0.1))
116
+
117
+ image, error = query(prompt, negative_prompt, steps, cfg_scale, sampler, seed, strength, width, height, num_inference_steps, guidance_scale, num_return_sequences, temperature, top_k, top_p, eta)
118
 
119
  if error:
120
  return jsonify({"error": error}), 400