https://github.com/robothy/sdwebui-java-sdk
Java SDK for stable-diffusion-webui
https://github.com/robothy/sdwebui-java-sdk
aigc image-to-image java stable-diffusion stable-diffusion-api stable-diffusion-java stable-diffusion-webui text-to-image
Last synced: 6 months ago
JSON representation
Java SDK for stable-diffusion-webui
- Host: GitHub
- URL: https://github.com/robothy/sdwebui-java-sdk
- Owner: Robothy
- License: apache-2.0
- Created: 2023-10-10T14:55:42.000Z (over 2 years ago)
- Default Branch: main
- Last Pushed: 2024-06-14T03:00:39.000Z (over 1 year ago)
- Last Synced: 2025-03-22T13:19:57.314Z (11 months ago)
- Topics: aigc, image-to-image, java, stable-diffusion, stable-diffusion-api, stable-diffusion-java, stable-diffusion-webui, text-to-image
- Language: Java
- Homepage:
- Size: 781 KB
- Stars: 31
- Watchers: 1
- Forks: 6
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Stable Diffusion Webui Java SDK
[](https://github.com/Robothy/sdwebui-java-sdk/actions/workflows/build.yml)
[](https://github.com/robothy/sdwebui-java-sdk/blob/main/LICENSE)
[](https://search.maven.org/artifact/io.github.robothy/sdwebui-java-sdk/)
sdwebui-java-sdk is a Java library for building Java applications that integrate with [Stable Diffusion Webui](https://github.com/AUTOMATIC1111/stable-diffusion-webui).
## Usage
### Add Denendencies
Maven
```
io.github.robothy
sdwebui-java-sdk
${latest-version}
```
Gradle
```
implementation "io.github.robothy:sdwebui-java-sdk:${latest-version}"
```
### Create `SdWebui` instance
```java
SdWebui sd = SdWebui.create("http://localhost:7860");
```
### Text to Image
```java
Txt2ImgResult txt2ImgResult = sd.txt2Img(Txt2ImageOptions.builder()
.prompt("1dog")
.samplerName("DPM++ 2M Karras")
.steps(20)
.cfgScale(7)
.seed(32749528)
.build());
Path step1Path = Paths.get("docs/images/txt2img-dog.png");
Files.write(step1Path, Base64.getDecoder().decode(txt2ImgResult.getImages().get(0)));
```

### Image to Image
```java
Image2ImageResult image2ImageResult = sd.img2img(Image2ImageOptions.builder()
.prompt("1dog, glass")
.negativePrompt("bad fingers")
.samplerName("DPM++ 2M Karras")
.seed(32749528)
.cfgScale(7)
.denoisingStrength(0.3)
.initImages(List.of(txt2ImgResult.getImages().get(0)))
.build());
String base64img = image2ImageResult.getImages().get(0);
Path filepath = Paths.get("docs/images/img2img-dog.png");
Files.write(filepath, Base64.getDecoder().decode(base64img));
```
