Open huangyous opened 1 year ago
See this discussion for some example use cases and sample scripts using the API.
I'm not aware of any further API documentation (beyond the links in that thread). However, I've been able to work with the API and have it running smoothly alongside a Ruby on Rails app. It's possible! 🙂
To address your specific questions:
I hope this information is helpful!
thanks for replying,I found this "@routes.post("/upload/image")" in server.py,so I think ComfyUI can handler file uploading itself,but I can't find any usage example
thanks for replying,I found this "@routes.post("/upload/image")" in server.py,so I think ComfyUI can handler file uploading itself,but I can't find any usage example
You can see usage of them in .js files under /ComfyUI/web/...
@huangyous Great find - that's helpful to know!
thanks for replying,I found this "@routes.post("/upload/image")" in server.py,so I think ComfyUI can handler file uploading itself,but I can't find any usage example
You can see usage of them in .js files under
/ComfyUI/web/...
thanks
Just following up on this, is there any way to use the API to poll for the progress percentage?
-edit-
Stupid question. Ignore me.
Sounds like you all have made progress in working with the API, but thought I'd share that I created an extension to convert any comfyui workflow (including custom nodes) into executable python code that will run without relying on the comfyui server.
If you are comfortable in Python, it may be more straightforward to use than the API. If interested, check it out here: https://github.com/pydn/ComfyUI-to-Python-Extension
Just following up on this, is there any way to use the API to poll for the progress percentage?
-edit-
Stupid question. Ignore me.
how you get progress info in API?
If you're using the websocket it's transmitted automatically when you recv. In the websocket example, add a "print(str(out))" after the recv and you'll see everything it sends.
If you're using the websocket it's transmitted automatically when you recv. In the websocket example, add a "print(str(out))" after the recv and you'll see everything it sends.
thank you!
Sounds like you all have made progress in working with the API, but thought I'd share that I created an extension to convert any comfyui workflow (including custom nodes) into executable python code that will run without relying on the comfyui server.
If you are comfortable in Python, it may be more straightforward to use than the API. If interested, check it out here: https://github.com/pydn/ComfyUI-to-Python-Extension
really nice work. If the official of ComfyUI can merge it, it would be better. Although this feature maybe divergent to the core features.
Could anyone help me to use the @routes.post("/upload/image") API?
@Yash-Patidar just in case you still need to post an image to that route, here is my python code:
data = {"subfolder": "your_subfolder"}
files = {'image': (the_file_name_on_server_you_want, open(image_path, 'rb'))}
resp = requests.post("http://127.0.0.1:8188/upload/image", files=files, data=data)
print(resp.content)
In the upload/mask endpoint what is the originalRef payload supposed to look like?
@Yash-Patidar just in case you still need to post an image to that route, here is my python code:
data = {"subfolder": "your_subfolder"} files = {'image': (the_file_name_on_server_you_want, open(image_path, 'rb'))} resp = requests.post("http://127.0.0.1:8188/upload/image", files=files, data=data) print(resp.content)
saved me from urllib 's error of default method. Thank you
I found these API keywords in server.py.Would you add some use case of these? BTW 1.the API "/prompt" will generate pic file in the output folder,is there a method to delete the file after I download the file? BTW 2.When I use img2img with API,I have to upload image file to input folder first.Do I have to write my own file uploader program?
@routes.get('/ws') @routes.get("/") @routes.get("/embeddings") @routes.get("/extensions") @routes.post("/upload/image") @routes.post("/upload/mask") @routes.get("/view") @routes.get("/view_metadata/{folder_name}") @routes.get("/system_stats") @routes.get("/prompt") @routes.get("/object_info") @routes.get("/object_info/{node_class}") @routes.get("/history") @routes.get("/history/{prompt_id}") @routes.get("/queue") @routes.post("/prompt") @routes.post("/queue") @routes.post("/interrupt") @routes.post("/history")