dreamdrop-art commited on
Commit
7e726ee
·
1 Parent(s): e042973

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +15 -12
app.py CHANGED
@@ -20,18 +20,21 @@ def query(payload, model):
20
  return response.content
21
 
22
  def hf_inference(prompt, negative, model, steps, sampler, guidance, width, height, seed):
23
- image_bytes = query(payload={
24
- "inputs": f"{prompt}",
25
- "parameters": {
26
- "negative_prompt": f"{negative}",
27
- "num_inference_steps": steps,
28
- "guidance_scale": guidance,
29
- "width": width, "height": height,
30
- "seed": seed,
31
- },
32
- }, model=model)
33
- image = Image.open(io.BytesIO(image_bytes))
34
- return image
 
 
 
35
 
36
 
37
 
 
20
  return response.content
21
 
22
  def hf_inference(prompt, negative, model, steps, sampler, guidance, width, height, seed):
23
+ try:
24
+ image_bytes = query(payload={
25
+ "inputs": f"{prompt}",
26
+ "parameters": {
27
+ "negative_prompt": f"{negative}",
28
+ "num_inference_steps": steps,
29
+ "guidance_scale": guidance,
30
+ "width": width, "height": height,
31
+ "seed": seed,
32
+ },
33
+ }, model=model)
34
+ image = Image.open(io.BytesIO(image_bytes))
35
+ return image
36
+ expect PIL.UnidentifiedImageError:
37
+ gr.Warning("This model is not loaded now. Try others models.")
38
 
39
 
40