Werli commited on
Commit
65418e0
·
verified ·
1 Parent(s): 58ae8b7

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +20 -8
app.py CHANGED
@@ -110,18 +110,26 @@ def extract_model_info(workflow_data):
110
  models.append(inputs.get("model_path", "Unknown"))
111
  return "\n".join(models) if models else "Not found"
112
 
113
- def extract_image_info(workflow_data):
114
- width = height = batch_size = "Not found"
 
 
 
 
 
 
 
 
 
 
115
  if not isinstance(workflow_data, dict):
116
- return width, height, batch_size
117
  for node in workflow_data.values():
118
  if isinstance(node, dict) and node.get("class_type", "") == "EmptyLatentImage":
119
  inputs = node.get("inputs", {})
120
- width = inputs.get("width", "Not found")
121
- height = inputs.get("height", "Not found")
122
  batch_size = inputs.get("batch_size", "Not found")
123
  break
124
- return str(width), str(height), str(batch_size)
125
 
126
  def extract_nodes_info(workflow_data):
127
  if not isinstance(workflow_data, dict):
@@ -155,7 +163,11 @@ def process_single_image(image_path):
155
  positive, negative = extract_prompts(workflow_data)
156
  loras = extract_loras(workflow_data)
157
  models = extract_model_info(workflow_data)
158
- width, height, batch = extract_image_info(workflow_data)
 
 
 
 
159
  nodes = extract_nodes_info(workflow_data)
160
  full_json = extract_workflow_as_json(workflow_data)
161
  else:
@@ -370,4 +382,4 @@ with gr.Blocks(title="ComfyUI Workflow Extractor", css=css, theme="Werli/Purple-
370
  gr.Markdown("---\n💡 **Note:** It's under development.")
371
 
372
  if __name__ == "__main__":
373
- demo.queue(max_size=10).launch(show_api=False, show_error=True)
 
110
  models.append(inputs.get("model_path", "Unknown"))
111
  return "\n".join(models) if models else "Not found"
112
 
113
+ def extract_image_info_from_file(image_path):
114
+ """Extract actual image dimensions from the image file itself"""
115
+ try:
116
+ with Image.open(image_path) as img:
117
+ width, height = img.size
118
+ return str(width), str(height)
119
+ except Exception as e:
120
+ return "Not found", "Not found"
121
+
122
+ def extract_batch_size(workflow_data):
123
+ """Extract batch size from workflow data"""
124
+ batch_size = "Not found"
125
  if not isinstance(workflow_data, dict):
126
+ return batch_size
127
  for node in workflow_data.values():
128
  if isinstance(node, dict) and node.get("class_type", "") == "EmptyLatentImage":
129
  inputs = node.get("inputs", {})
 
 
130
  batch_size = inputs.get("batch_size", "Not found")
131
  break
132
+ return str(batch_size)
133
 
134
  def extract_nodes_info(workflow_data):
135
  if not isinstance(workflow_data, dict):
 
163
  positive, negative = extract_prompts(workflow_data)
164
  loras = extract_loras(workflow_data)
165
  models = extract_model_info(workflow_data)
166
+
167
+ # Get actual image dimensions instead of workflow dimensions
168
+ width, height = extract_image_info_from_file(image_path)
169
+ batch = extract_batch_size(workflow_data)
170
+
171
  nodes = extract_nodes_info(workflow_data)
172
  full_json = extract_workflow_as_json(workflow_data)
173
  else:
 
382
  gr.Markdown("---\n💡 **Note:** It's under development.")
383
 
384
  if __name__ == "__main__":
385
+ demo.queue(max_size=10).launch(show_api=False, show_error=True)