Geek7 commited on
Commit
3285b51
·
verified ·
1 Parent(s): 5bc3f97

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +17 -17
app.py CHANGED
@@ -32,23 +32,23 @@ default_models = models[:num_models]
32
  inference_timeout = 600
33
 
34
  #async def infer(model_str, prompt, seed=1, timeout=inference_timeout):
35
- kwargs = {"seed": seed}
36
- task = asyncio.create_task(asyncio.to_thread(models_load[model_str].fn, prompt=prompt, **kwargs, token=HF_TOKEN))
37
- await asyncio.sleep(0)
38
- try:
39
- result = await asyncio.wait_for(task, timeout=timeout)
40
- except (Exception, asyncio.TimeoutError) as e:
41
- print(e)
42
- print(f"Task timed out: {model_str}")
43
- if not task.done():
44
- task.cancel()
45
- result = None
46
- if task.done() and result is not None:
47
- with lock:
48
- png_path = "image.png"
49
- result.save(png_path)
50
- return png_path
51
- return None
52
 
53
 
54
 
 
32
  inference_timeout = 600
33
 
34
  #async def infer(model_str, prompt, seed=1, timeout=inference_timeout):
35
+ # kwargs = {"seed": seed}
36
+ #task = asyncio.create_task(asyncio.to_thread(models_load[model_str].fn, prompt=prompt, **kwargs, token=HF_TOKEN))
37
+ # await asyncio.sleep(0)
38
+ # try:
39
+ # result = await asyncio.wait_for(task, timeout=timeout)
40
+ # except (Exception, asyncio.TimeoutError) as e:
41
+ # print(e)
42
+ # print(f"Task timed out: {model_str}")
43
+ # if not task.done():
44
+ # task.cancel()
45
+ # result = None
46
+ # if task.done() and result is not None:
47
+ # with lock:
48
+ # png_path = "image.png"
49
+ # result.save(png_path)
50
+ # return png_path
51
+ #return None
52
 
53
 
54