Comments (5)
Hi, thanks!!
I got the API working, mainly by inspecting the calls made by the web GUI.
There are two fields in the posted data that I don't know what they're for and that seem to be mandatory:
- fn_index: when inspecting, it was set to 10. I tried other values of 0 or 1, but then there's an error. It works with 10, but what's the purpose of this field?
- session_hash: I can guess that this is used by the GUI to identify when making subsequent calls to the server. It works with a fixed string (that I copied when inspecting the GUI). I suppose it would be better if I'd generate my own hashes, but how are they built?
The data array contains all the settings that are available in the GUI. So far I copied the defaults (again: upon inspection) and only tried modifying the text and the size fields.
Here's code that works for me:
#!/bin/sh
curl --header "Content-Type: application/json" \
--request POST \
--data '{"fn_index":10,"data": ["<text goes here>","","None","None",20,"Euler a",false,false,1,1,7,-1,-1,0,0,0,false,512,512,false,false,0.7,"None",false,false,null,"","Seed","","Steps","",true,null,"",""],"session_hash":"ejz5r41u2pi2"}' \
http://localhost:7860/api/predict/
And in Python:
#!/usr/bin/python3
import requests
from requests.structures import CaseInsensitiveDict
import json
from base64 import urlsafe_b64decode
url = "http://localhost:7860/api/predict/"
headers = CaseInsensitiveDict()
headers["Content-Type"] = "application/json"
text = "<text goes here>"
size = 512
data_json = {"fn_index":10,"data": [text,"","None","None",20,"Euler a",False,False,1,1,7,-1,-1,0,0,0,False,size,size,False,False,0.7,"None",False,False,None,"","Seed","","Steps","",True,None,"",""],"session_hash":"ejz5r41u2pi"}
data = json.dumps(data_json)
resp = requests.post(url, headers=headers, data=data)
if resp.status_code == 200:
with open("predict.png","wb") as f:
b64string = resp.json()["data"][0][0].split(',')[1]
f.write(urlsafe_b64decode(b64string))
print("Image saved to file")
else:
print(json.dumps(resp.json()))
print("Status code: " + str(resp.status_code))
print("Nothing saved to file")
from stable-diffusion-webui-docker.
@vicmortelmans when you open the ui, there is a button at the bottom to view the api, you can then curl against it with the prompts / parameters, and get the result from the output folder. I haven't tried it personally, but it should work, in theory at least.
from stable-diffusion-webui-docker.
Glad it worked! the questions you have rely on the internals of gradio and the UI itself, which is unfortunately out of scope of this repo (here are the containers only).
You can definitely try asking your questions in the main repo:
https://github.com/AUTOMATIC1111/stable-diffusion-webui
The community there is much larger and you would probably find the answers you are looking for 👍
from stable-diffusion-webui-docker.
This issue is stale because it has been open 14 days with no activity. Remove stale label or comment or this will be closed in 7 days.
from stable-diffusion-webui-docker.
This issue was closed because it has been stalled for 7 days with no activity.
from stable-diffusion-webui-docker.
Related Issues (20)
- E: You don't have enough free space in /var/cache/apt/archives/. HOT 2
- I update 1.6 to 1.7 HOT 1
- use AnimateDiff mportError: cannot import name 'animatediff_i2ibatch
- comfy 的docker image是否沒有更新了
- exec format error HOT 2
- ComfyUI Out of Date HOT 3
- Cannot start due to wcwidth error
- error during container init: unable to apply apparmor profile HOT 1
- Updating auto1111 HOT 1
- Stuck at "removing nvidia-cudnn-cu11" forever HOT 4
- Unexpected error from cudaGetDeviceCount() HOT 13
- Docker install fails due to "missing" library HOT 11
- Automatic UI and Invoke fail to start (throwing exceptions) HOT 12
- Cannot load container on Ubuntu 24.04 HOT 4
- ModuleNotFoundError: No module named 'torch._custom_ops' HOT 3
- Cannot install auto HOT 1
- Redundant code in Auto
- Failed building in windows HOT 1
- install ComfyUI Manager when building the Comfy docker image
- Unable to build the "auto" (AUTOMATIC1111) image via docker build HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from stable-diffusion-webui-docker.