phamngoctukts commited on
Commit
9ebf935
·
verified ·
1 Parent(s): 77def59

Update render.py

Browse files
Files changed (1) hide show
  1. render.py +4 -4
render.py CHANGED
@@ -30,7 +30,7 @@ def get_history(prompt_id):
30
  with urllib.request.urlopen(f"http://{server_address}/history/{prompt_id}") as response:
31
  return json.loads(response.read())
32
 
33
- def get_images(ws, prompt):
34
  progress=gr.Progress(track_tqdm=True)
35
  prompt_id = queue_prompt(prompt)['prompt_id']
36
  output_images = {}
@@ -46,7 +46,7 @@ def get_images(ws, prompt):
46
  percentage = int((current_progress / max_progress) * 100)
47
  if percentage >= last_reported_percentage + 10:
48
  last_reported_percentage = percentage
49
-
50
  elif message['type'] == 'executing':
51
  data = message['data']
52
  if data['node'] is None and data['prompt_id'] == prompt_id:
@@ -72,7 +72,7 @@ def pil_to_base64(image):
72
  base64_string=base64.b64encode(buffer.getvalue()).decode("utf-8")
73
  return f"data:image/png;base64,{base64_string}"
74
 
75
- def generate_images(positive_prompt, image):
76
 
77
  ws = websocket.WebSocket()
78
  ws_url = f"ws://{server_address}/ws?clientId={client_id}"
@@ -87,7 +87,7 @@ def generate_images(positive_prompt, image):
87
  data["62"]["inputs"]["images"] = ["61",0]
88
  seed = random.randint(1, 1000000000)
89
  data["47"]["inputs"]["noise_seed"] = seed
90
- images = get_images(ws, data)
91
  ws.close()
92
  for node_id in images:
93
  for image_data in images[node_id]:
 
30
  with urllib.request.urlopen(f"http://{server_address}/history/{prompt_id}") as response:
31
  return json.loads(response.read())
32
 
33
+ def get_images(ws,prompt,progress):
34
  progress=gr.Progress(track_tqdm=True)
35
  prompt_id = queue_prompt(prompt)['prompt_id']
36
  output_images = {}
 
46
  percentage = int((current_progress / max_progress) * 100)
47
  if percentage >= last_reported_percentage + 10:
48
  last_reported_percentage = percentage
49
+ progress(percentage/100)
50
  elif message['type'] == 'executing':
51
  data = message['data']
52
  if data['node'] is None and data['prompt_id'] == prompt_id:
 
72
  base64_string=base64.b64encode(buffer.getvalue()).decode("utf-8")
73
  return f"data:image/png;base64,{base64_string}"
74
 
75
+ def generate_images(positive_prompt,image,progress):
76
 
77
  ws = websocket.WebSocket()
78
  ws_url = f"ws://{server_address}/ws?clientId={client_id}"
 
87
  data["62"]["inputs"]["images"] = ["61",0]
88
  seed = random.randint(1, 1000000000)
89
  data["47"]["inputs"]["noise_seed"] = seed
90
+ images = get_images(ws,data,progress)
91
  ws.close()
92
  for node_id in images:
93
  for image_data in images[node_id]: