├── imgs ├── a.jpeg ├── b.jpeg ├── c.jpeg ├── d.jpg └── e.jpg ├── outs └── imgs │ ├── aDetailer-0.png │ ├── aDetailer-1.png │ ├── aDetailer-2.png │ ├── aDetailer-3.png │ ├── controlnet-0.png │ ├── controlnet-1.png │ ├── controlnet-2.png │ ├── controlnet-3.png │ └── controlnet-4.png ├── .gitignore ├── src └── main │ └── java │ └── org │ └── springbus │ └── sd │ ├── model │ ├── ParamaterType.java │ ├── Img2ImgModel.java │ ├── Upscaler.java │ ├── ControlNet.java │ ├── WebUIApiResult.java │ ├── HiResUpscaler.java │ ├── PILImage.java │ └── Txt2ImgModel.java │ ├── extensions │ ├── Plugin.java │ ├── ControlNetUnit.java │ ├── Roop.java │ └── ADetailer.java │ ├── utils │ ├── JacksonUtil.java │ ├── ImageUtil.java │ └── HttpClientUtil.java │ ├── Main.java │ └── WebUIApi.java ├── .github └── workflows │ └── maven-publish.yml ├── pom.xml └── README.md /imgs/a.jpeg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tomj2ee/java-sdwebuiapi/HEAD/imgs/a.jpeg -------------------------------------------------------------------------------- /imgs/b.jpeg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tomj2ee/java-sdwebuiapi/HEAD/imgs/b.jpeg -------------------------------------------------------------------------------- /imgs/c.jpeg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tomj2ee/java-sdwebuiapi/HEAD/imgs/c.jpeg -------------------------------------------------------------------------------- /imgs/d.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tomj2ee/java-sdwebuiapi/HEAD/imgs/d.jpg -------------------------------------------------------------------------------- /imgs/e.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tomj2ee/java-sdwebuiapi/HEAD/imgs/e.jpg -------------------------------------------------------------------------------- /outs/imgs/aDetailer-0.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tomj2ee/java-sdwebuiapi/HEAD/outs/imgs/aDetailer-0.png -------------------------------------------------------------------------------- /outs/imgs/aDetailer-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tomj2ee/java-sdwebuiapi/HEAD/outs/imgs/aDetailer-1.png -------------------------------------------------------------------------------- /outs/imgs/aDetailer-2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tomj2ee/java-sdwebuiapi/HEAD/outs/imgs/aDetailer-2.png -------------------------------------------------------------------------------- /outs/imgs/aDetailer-3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tomj2ee/java-sdwebuiapi/HEAD/outs/imgs/aDetailer-3.png -------------------------------------------------------------------------------- /outs/imgs/controlnet-0.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tomj2ee/java-sdwebuiapi/HEAD/outs/imgs/controlnet-0.png -------------------------------------------------------------------------------- /outs/imgs/controlnet-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tomj2ee/java-sdwebuiapi/HEAD/outs/imgs/controlnet-1.png -------------------------------------------------------------------------------- /outs/imgs/controlnet-2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tomj2ee/java-sdwebuiapi/HEAD/outs/imgs/controlnet-2.png -------------------------------------------------------------------------------- /outs/imgs/controlnet-3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tomj2ee/java-sdwebuiapi/HEAD/outs/imgs/controlnet-3.png -------------------------------------------------------------------------------- /outs/imgs/controlnet-4.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tomj2ee/java-sdwebuiapi/HEAD/outs/imgs/controlnet-4.png -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | .idea 2 | .classpath 3 | .project 4 | *.iml 5 | target/ 6 | .DS_Store 7 | .gitattributes 8 | ./.idea 9 | ./target 10 | 11 | -------------------------------------------------------------------------------- /src/main/java/org/springbus/sd/model/ParamaterType.java: -------------------------------------------------------------------------------- 1 | package org.springbus.sd.model; 2 | 3 | public enum ParamaterType { 4 | LIST, 5 | MAP, 6 | 7 | } 8 | -------------------------------------------------------------------------------- /src/main/java/org/springbus/sd/extensions/Plugin.java: -------------------------------------------------------------------------------- 1 | package org.springbus.sd.extensions; 2 | 3 | import com.fasterxml.jackson.annotation.JsonIgnore; 4 | 5 | public interface Plugin { 6 | Object toDict(); 7 | @JsonIgnore 8 | String getName(); 9 | } 10 | -------------------------------------------------------------------------------- /src/main/java/org/springbus/sd/model/Img2ImgModel.java: -------------------------------------------------------------------------------- 1 | package org.springbus.sd.model; 2 | 3 | import java.util.List; 4 | 5 | public class Img2ImgModel extends Txt2ImgModel { 6 | 7 | public List images; 8 | public Integer resize_mode = 0; 9 | public Float denoising_strength = 0.75f; 10 | public Float image_cfg_scale = 1.5f; 11 | public String mask_image; // PIL Image mask 12 | public Integer mask_blur = 4; 13 | public Integer inpainting_fill = 0; 14 | public Boolean inpaint_full_res = true; 15 | public Integer inpaint_full_res_padding = 0; 16 | public Integer inpainting_mask_invert = 0; 17 | public Integer initial_noise_multiplier = 1; 18 | 19 | } 20 | -------------------------------------------------------------------------------- /src/main/java/org/springbus/sd/model/Upscaler.java: -------------------------------------------------------------------------------- 1 | package org.springbus.sd.model; 2 | 3 | public class Upscaler { 4 | public final static String none = "None"; 5 | public final static String Lanczos = "Lanczos"; 6 | public final static String Nearest = "Nearest"; 7 | public final static String LDSR = "LDSR"; 8 | public final static String BSRGAN = "BSRGAN"; 9 | public final static String ESRGAN_4x = "ESRGAN_4x"; 10 | public final static String R_ESRGAN_General_4xV3 = "R-ESRGAN General 4xV3"; 11 | public final static String ScuNET_GAN = "ScuNET GAN"; 12 | public final static String ScuNET_PSNR = "ScuNET PSNR"; 13 | public final static String SwinIR_4x = "SwinIR 4x"; 14 | } 15 | -------------------------------------------------------------------------------- /src/main/java/org/springbus/sd/model/ControlNet.java: -------------------------------------------------------------------------------- 1 | package org.springbus.sd.model; 2 | 3 | public class ControlNet { 4 | public String input_image; 5 | public String mask = ""; 6 | public String module = "None"; 7 | public String model = "None"; 8 | public Float weight = 1.0f; 9 | public String resize_mode = "Resize and Fill"; 10 | public Boolean lowvram = false; 11 | public Integer processor_res = 512; 12 | public Float threshold_a = 64f; 13 | public Float threshold_b = 64f; 14 | public Float guidance = 1.0f; 15 | public Float guidance_start = 0.0f; 16 | public Float guidance_end = 1.0f; 17 | public Integer control_mode = 0; 18 | public Boolean pixel_perfect = false; 19 | } 20 | 21 | -------------------------------------------------------------------------------- /src/main/java/org/springbus/sd/extensions/ControlNetUnit.java: -------------------------------------------------------------------------------- 1 | package org.springbus.sd.extensions; 2 | 3 | import org.springbus.sd.model.ControlNet; 4 | 5 | import java.util.ArrayList; 6 | import java.util.List; 7 | 8 | public class ControlNetUnit implements Plugin { 9 | 10 | private List controlNets=new ArrayList<>(); 11 | public ControlNetUnit(List net){ 12 | controlNets.addAll(net); 13 | } 14 | public ControlNetUnit(ControlNet net){ 15 | controlNets.add(net); 16 | } 17 | 18 | @Override 19 | public Object toDict() { 20 | return controlNets; 21 | } 22 | 23 | @Override 24 | public String getName() { 25 | return "ControlNet"; 26 | } 27 | 28 | 29 | } 30 | 31 | -------------------------------------------------------------------------------- /src/main/java/org/springbus/sd/model/WebUIApiResult.java: -------------------------------------------------------------------------------- 1 | package org.springbus.sd.model; 2 | 3 | import java.util.ArrayList; 4 | import java.util.HashMap; 5 | import java.util.List; 6 | import java.util.Map; 7 | 8 | public class WebUIApiResult { 9 | 10 | private final List images = new ArrayList<>(); 11 | public final Map parameters = new HashMap<>(); 12 | public final Map info = new HashMap<>(); 13 | 14 | 15 | public PILImage getImage() { 16 | if (images.size() > 0) { 17 | return this.images.get(0); 18 | } 19 | return null; 20 | } 21 | 22 | public List getImages() { 23 | return images; 24 | } 25 | 26 | public void addImage(String base64Img) { 27 | images.add(new PILImage(base64Img)); 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /src/main/java/org/springbus/sd/model/HiResUpscaler.java: -------------------------------------------------------------------------------- 1 | package org.springbus.sd.model; 2 | 3 | public class HiResUpscaler { 4 | public static final String none = "None"; 5 | public static final String Latent = "Latent"; 6 | public static final String LatentAntialiased = "Latent (antialiased)"; 7 | public static final String LatentBicubic = "Latent (bicubic)"; 8 | public static final String LatentBicubicAntialiased = "Latent (bicubic antialiased)"; 9 | public static final String LatentNearest = "Latent (nearist)"; 10 | public static final String LatentNearestExact = "Latent (nearist-exact)"; 11 | public static final String Lanczos = "Lanczos"; 12 | public static final String Nearest = "Nearest"; 13 | public static final String ESRGAN_4x = "ESRGAN_4x"; 14 | public static final String LDSR = "LDSR"; 15 | public static final String ScuNET_GAN = "ScuNET GAN"; 16 | public static final String ScuNET_PSNR = "ScuNET PSNR"; 17 | public static final String SwinIR_4x = "SwinIR 4x"; 18 | } -------------------------------------------------------------------------------- /.github/workflows/maven-publish.yml: -------------------------------------------------------------------------------- 1 | # This workflow will build a package using Maven and then publish it to GitHub packages when a release is created 2 | # For more information see: https://github.com/actions/setup-java/blob/main/docs/advanced-usage.md#apache-maven-with-a-settings-path 3 | 4 | name: Maven Package 5 | 6 | on: 7 | release: 8 | types: [created] 9 | 10 | jobs: 11 | build: 12 | 13 | runs-on: ubuntu-latest 14 | permissions: 15 | contents: read 16 | packages: write 17 | 18 | steps: 19 | - uses: actions/checkout@v3 20 | - name: Set up JDK 11 21 | uses: actions/setup-java@v3 22 | with: 23 | java-version: '11' 24 | distribution: 'temurin' 25 | server-id: github # Value of the distributionManagement/repository/id field of the pom.xml 26 | settings-path: ${{ github.workspace }} # location for the settings.xml file 27 | 28 | - name: Build with Maven 29 | run: mvn -B package --file pom.xml 30 | 31 | - name: Publish to GitHub Packages Apache Maven 32 | run: mvn deploy -s $GITHUB_WORKSPACE/settings.xml 33 | env: 34 | GITHUB_TOKEN: ${{ github.token }} 35 | -------------------------------------------------------------------------------- /src/main/java/org/springbus/sd/model/PILImage.java: -------------------------------------------------------------------------------- 1 | package org.springbus.sd.model; 2 | 3 | import org.springbus.sd.utils.ImageUtil; 4 | 5 | import javax.imageio.ImageIO; 6 | import java.awt.image.BufferedImage; 7 | import java.io.File; 8 | import java.io.IOException; 9 | 10 | public class PILImage { 11 | private String base64Img; 12 | public PILImage(String base64Img){ 13 | this.base64Img=base64Img; 14 | } 15 | public void save(String imgPath){ 16 | ImageUtil.base64ToImg(base64Img,imgPath); 17 | } 18 | public BufferedImage resize(int w,int h) { 19 | BufferedImage image = ImageUtil.base64ToImg(base64Img); 20 | BufferedImage bufferedImage = ImageUtil.reSize(image, w, h); 21 | return bufferedImage; 22 | } 23 | public void resizeAndSaveTo(int w,int h,String imgPath) throws IOException { 24 | BufferedImage image = ImageUtil.base64ToImg(base64Img); 25 | BufferedImage bufferedImage = ImageUtil.reSize(image, w, h); 26 | save(bufferedImage,imgPath); 27 | } 28 | public void save(BufferedImage bufferedImage,String imgPath) throws IOException { 29 | ImageIO.write(bufferedImage,"png",new File(imgPath)); 30 | } 31 | 32 | } 33 | -------------------------------------------------------------------------------- /src/main/java/org/springbus/sd/extensions/Roop.java: -------------------------------------------------------------------------------- 1 | package org.springbus.sd.extensions; 2 | 3 | import java.util.ArrayList; 4 | import java.util.List; 5 | 6 | public class Roop implements Plugin { 7 | public String img; 8 | public boolean enable = true; 9 | public String faces_index = "0"; 10 | public String model = ""; 11 | public String face_restorer_name = "GFPGAN"; 12 | public float face_restorer_visibility = 1f; 13 | public String upscaler_name = "R-ESRGAN 4x+"; 14 | public Float upscaler_scale = 1f; 15 | public Float upscaler_visibility = 1f; 16 | public boolean swap_in_source = false; 17 | public boolean swap_in_generated = true; 18 | 19 | 20 | public Object toDict() { 21 | List dict = new ArrayList<>(); 22 | dict.add(this.img); 23 | dict.add(this.enable); 24 | dict.add(this.faces_index); 25 | dict.add(this.model); 26 | dict.add(this.face_restorer_name); 27 | dict.add(this.face_restorer_visibility); 28 | dict.add(this.upscaler_name); 29 | dict.add(this.upscaler_scale); 30 | dict.add(this.upscaler_visibility); 31 | dict.add(this.swap_in_source); 32 | dict.add(this.swap_in_generated); 33 | return dict; 34 | } 35 | 36 | @Override 37 | public String getName() { 38 | return "roop"; 39 | } 40 | 41 | } 42 | -------------------------------------------------------------------------------- /pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 4.0.0 6 | 7 | org.springbus 8 | webuiapi 9 | 1.0-SNAPSHOT 10 | JAVA API client for AUTOMATIC1111/stable-diffusion-webui 11 | 12 | 13 | 8 14 | 8 15 | UTF-8 16 | 17 | 18 | 19 | 20 | org.apache.httpcomponents 21 | httpclient 22 | 4.5.14 23 | 24 | 25 | 26 | com.fasterxml.jackson.datatype 27 | jackson-datatype-jsr310 28 | 2.14.2 29 | 30 | 31 | 32 | 33 | net.logstash.logback 34 | logstash-logback-encoder 35 | 7.3 36 | 37 | 38 | 39 | org.slf4j 40 | slf4j-api 41 | 2.0.7 42 | 43 | 44 | 45 | 46 | 47 | -------------------------------------------------------------------------------- /src/main/java/org/springbus/sd/extensions/ADetailer.java: -------------------------------------------------------------------------------- 1 | package org.springbus.sd.extensions; 2 | 3 | import com.fasterxml.jackson.annotation.JsonIgnore; 4 | 5 | import java.util.ArrayList; 6 | import java.util.List; 7 | 8 | public class ADetailer implements Plugin { 9 | 10 | public String ad_model = "None"; 11 | public String ad_prompt = ""; 12 | public String ad_negative_prompt = ""; 13 | public Float ad_confidence = 0.3f; 14 | public Float ad_mask_min_ratio = 0.0f; 15 | public Float ad_mask_max_ratio = 1.0f; 16 | public Integer ad_dilate_erode = 4; 17 | public Integer ad_x_offset = 0; 18 | public Integer ad_y_offset = 0; 19 | //Literal["None", "Merge", "Merge and Invert"] = "None", 20 | public String ad_mask_merge_invert="None"; 21 | public Integer ad_mask_blur = 4; 22 | public Float ad_denoising_strength = 0.4f; 23 | public boolean ad_inpaint_only_masked = true; 24 | public Integer ad_inpaint_only_masked_padding = 32; 25 | public boolean ad_use_inpaint_width_height = false; 26 | public Integer ad_inpaint_width = 512; 27 | public Integer ad_inpaint_height = 512; 28 | public boolean ad_use_steps = false; 29 | public Integer ad_steps = 28; 30 | public boolean ad_use_cfg_scale = false; 31 | public Float ad_cfg_scale = 7.0f; 32 | 33 | public boolean ad_use_noise_multiplier = false; 34 | public Float ad_noise_multiplier = 1.0f; 35 | public boolean ad_restore_face = false; 36 | public String ad_controlnet_model = "None"; 37 | public String ad_controlnet_module = "None"; 38 | public Float ad_controlnet_weight = 1.0f; 39 | public Float ad_controlnet_guidance_start = 0.0f; 40 | public Float ad_controlnet_guidance_end = 1.0f; 41 | public boolean is_api = true; 42 | 43 | @Override 44 | public Object toDict() { 45 | List dict=new ArrayList<>(); 46 | dict.add(true); 47 | dict.add(this); 48 | return dict; 49 | } 50 | 51 | @JsonIgnore 52 | @Override 53 | public String getName() { 54 | return "ADetailer"; 55 | } 56 | 57 | } -------------------------------------------------------------------------------- /src/main/java/org/springbus/sd/model/Txt2ImgModel.java: -------------------------------------------------------------------------------- 1 | package org.springbus.sd.model; 2 | 3 | import com.fasterxml.jackson.annotation.JsonIgnore; 4 | import org.springbus.sd.extensions.Plugin; 5 | 6 | import java.util.ArrayList; 7 | import java.util.HashMap; 8 | import java.util.List; 9 | import java.util.Map; 10 | 11 | public class Txt2ImgModel { 12 | public boolean enable_hr = false; 13 | public Float denoising_strength = 0.7f; 14 | public int firstphase_width = 0; 15 | public int firstphase_height = 0; 16 | public Float hr_scale = 2f; 17 | public String hr_upscaler="latent"; 18 | public int hr_second_pass_steps = 0; 19 | public int hr_resize_x = 0; 20 | public int hr_resize_y = 0; 21 | public String prompt = ""; 22 | public List styles = new ArrayList<>(); 23 | public Long seed = -1L; 24 | public Long subseed = -1L; 25 | public float subseed_strength = 0.0f; 26 | public float seed_resize_from_h = 0f; 27 | public float seed_resize_from_w = 0; 28 | public String sampler_name = "Euler a";//, # use this instead of sampler_index 29 | public Integer batch_size = 1; 30 | public Integer n_iter = 1; 31 | public Integer steps = 30; 32 | public Float cfg_scale = 7.0f; 33 | public Integer width = 512; 34 | public Integer height = 512; 35 | public boolean restore_faces = false; 36 | public boolean tiling = false; 37 | public boolean do_not_save_samples = false; 38 | public boolean do_not_save_grid = false; 39 | public String negative_prompt = ""; 40 | public Float eta = 1.0f; 41 | public Integer s_churn = 0; 42 | public Integer s_tmax = 0; 43 | public Integer s_tmin = 0; 44 | public Integer s_noise = 1; 45 | public final Map override_settings = new HashMap<>(); 46 | public boolean override_settings_restore_afterwards = true; 47 | public final List script_args = new ArrayList<>();// # List of arguments for the script "script_name" 48 | public String script_name = null; 49 | public boolean send_images = true; 50 | public boolean save_images = false; 51 | public final Map alwayson_scripts = new HashMap<>(); 52 | public String sampler_index = "Euler a"; 53 | 54 | 55 | public Txt2ImgModel withExtensions(Plugin plugin) { 56 | Map args = new HashMap<>(); 57 | args.put("args", plugin.toDict()); 58 | alwayson_scripts.put(plugin.getName(), args); 59 | return this; 60 | } 61 | } 62 | -------------------------------------------------------------------------------- /src/main/java/org/springbus/sd/utils/JacksonUtil.java: -------------------------------------------------------------------------------- 1 | package org.springbus.sd.utils; 2 | 3 | import com.fasterxml.jackson.core.JsonGenerationException; 4 | import com.fasterxml.jackson.core.JsonParseException; 5 | import com.fasterxml.jackson.databind.JavaType; 6 | import com.fasterxml.jackson.databind.JsonMappingException; 7 | import com.fasterxml.jackson.databind.ObjectMapper; 8 | import org.slf4j.Logger; 9 | import org.slf4j.LoggerFactory; 10 | 11 | import java.io.IOException; 12 | 13 | 14 | public class JacksonUtil { 15 | private static Logger logger = LoggerFactory.getLogger(JacksonUtil.class); 16 | 17 | private final static ObjectMapper objectMapper = new ObjectMapper(); 18 | public static ObjectMapper getInstance() { 19 | return objectMapper; 20 | } 21 | 22 | /** 23 | * bean、array、List、Map --> json 24 | * 25 | * @return json string 26 | */ 27 | public static String toJsonString(Object obj) { 28 | try { 29 | return getInstance().writeValueAsString(obj); 30 | } catch (JsonGenerationException e) { 31 | logger.error(e.getMessage(), e); 32 | } catch (JsonMappingException e) { 33 | logger.error(e.getMessage(), e); 34 | } catch (IOException e) { 35 | logger.error(e.getMessage(), e); 36 | } 37 | return null; 38 | } 39 | 40 | /** 41 | * string --> bean、Map、List(array) 42 | * 43 | * @param clazz 44 | * @return obj 45 | * @throws Exception 46 | */ 47 | public static T jsonToObject(String jsonStr, Class clazz) { 48 | try { 49 | return getInstance().readValue(jsonStr, clazz); 50 | } catch (JsonParseException e) { 51 | logger.error(e.getMessage(), e); 52 | } catch (JsonMappingException e) { 53 | logger.error(e.getMessage(), e); 54 | } catch (IOException e) { 55 | logger.error(e.getMessage(), e); 56 | } 57 | return null; 58 | } 59 | 60 | /** 61 | * string --> List... 62 | * 63 | * @return 64 | */ 65 | public static T jsonToObject(String jsonStr, Class parametrized, Class... parameterClasses) { 66 | try { 67 | JavaType javaType = getInstance().getTypeFactory().constructParametricType(parametrized, parameterClasses); 68 | return getInstance().readValue(jsonStr, javaType); 69 | } catch (JsonParseException e) { 70 | logger.error(e.getMessage(), e); 71 | } catch (JsonMappingException e) { 72 | logger.error(e.getMessage(), e); 73 | } catch (IOException e) { 74 | logger.error(e.getMessage(), e); 75 | } 76 | return null; 77 | } 78 | } 79 | -------------------------------------------------------------------------------- /src/main/java/org/springbus/sd/utils/ImageUtil.java: -------------------------------------------------------------------------------- 1 | package org.springbus.sd.utils; 2 | 3 | import javax.imageio.ImageIO; 4 | import java.awt.*; 5 | import java.awt.image.BufferedImage; 6 | import java.io.ByteArrayInputStream; 7 | import java.io.ByteArrayOutputStream; 8 | import java.io.File; 9 | import java.io.IOException; 10 | import java.util.Base64; 11 | 12 | public class ImageUtil { 13 | public static String img2Base64(String src) { 14 | ByteArrayOutputStream baos = null; 15 | try { 16 | String suffix = src.substring(src.lastIndexOf(".") + 1); 17 | File imageFile = new File(src); 18 | BufferedImage bufferedImage = ImageIO.read(imageFile); 19 | baos = new ByteArrayOutputStream(); 20 | ImageIO.write(bufferedImage, suffix, baos); 21 | byte[] bytes = baos.toByteArray(); 22 | return Base64.getEncoder().encodeToString(bytes); 23 | } catch (Exception e) { 24 | e.printStackTrace(); 25 | } finally { 26 | try { 27 | if (baos != null) { 28 | baos.close(); 29 | } 30 | } catch (IOException e) { 31 | e.printStackTrace(); 32 | } 33 | } 34 | return null; 35 | } 36 | 37 | public static void base64ToImg(String base64String, String imgToPath) { 38 | ByteArrayInputStream bais = null; 39 | try { 40 | String suffix = imgToPath.substring(imgToPath.lastIndexOf(".") + 1); 41 | byte[] bytes = Base64.getDecoder().decode(base64String); 42 | bais = new ByteArrayInputStream(bytes); 43 | BufferedImage bufferedImage = ImageIO.read(bais); 44 | File imageFile = new File(imgToPath); 45 | ImageIO.write(bufferedImage, suffix, imageFile); 46 | } catch (Exception e) { 47 | e.printStackTrace(); 48 | } finally { 49 | try { 50 | if (bais != null) { 51 | bais.close(); 52 | } 53 | } catch (IOException e) { 54 | e.printStackTrace(); 55 | } 56 | } 57 | } 58 | 59 | public static BufferedImage reSize(BufferedImage img, int newW, int newH) { 60 | int w = img.getWidth(); 61 | int h = img.getHeight(); 62 | BufferedImage dmg = new BufferedImage(newW, newH, img.getType()); 63 | Graphics2D g = dmg.createGraphics(); 64 | g.setRenderingHint(RenderingHints.KEY_INTERPOLATION, RenderingHints.VALUE_INTERPOLATION_BILINEAR); 65 | g.drawImage(img, 0, 0, newW, newH, 0, 0, w, h, null); 66 | g.dispose(); 67 | return dmg; 68 | } 69 | 70 | public static BufferedImage base64ToImg(String base64String) { 71 | ByteArrayInputStream bais = null; 72 | try { 73 | byte[] bytes = Base64.getDecoder().decode(base64String); 74 | bais = new ByteArrayInputStream(bytes); 75 | BufferedImage bufferedImage = ImageIO.read(bais); 76 | return bufferedImage; 77 | } catch (Exception e) { 78 | e.printStackTrace(); 79 | return null; 80 | } finally { 81 | try { 82 | if (bais != null) { 83 | bais.close(); 84 | } 85 | } catch (IOException e) { 86 | e.printStackTrace(); 87 | } 88 | } 89 | } 90 | 91 | public static String b64Img(String imgPath) { 92 | return "data:image/png;base64," + img2Base64(imgPath); 93 | } 94 | } -------------------------------------------------------------------------------- /src/main/java/org/springbus/sd/utils/HttpClientUtil.java: -------------------------------------------------------------------------------- 1 | package org.springbus.sd.utils; 2 | 3 | import org.apache.http.HttpEntity; 4 | import org.apache.http.HttpResponse; 5 | import org.apache.http.auth.AuthScope; 6 | import org.apache.http.auth.UsernamePasswordCredentials; 7 | import org.apache.http.client.CredentialsProvider; 8 | import org.apache.http.client.HttpClient; 9 | import org.apache.http.client.methods.HttpGet; 10 | import org.apache.http.client.methods.HttpPost; 11 | import org.apache.http.client.protocol.HttpClientContext; 12 | import org.apache.http.conn.ssl.SSLConnectionSocketFactory; 13 | import org.apache.http.entity.StringEntity; 14 | import org.apache.http.impl.client.BasicCredentialsProvider; 15 | import org.apache.http.impl.client.CloseableHttpClient; 16 | import org.apache.http.impl.client.HttpClients; 17 | import org.apache.http.ssl.SSLContextBuilder; 18 | import org.apache.http.util.EntityUtils; 19 | 20 | import javax.net.ssl.SSLContext; 21 | import java.nio.charset.StandardCharsets; 22 | import java.security.KeyManagementException; 23 | import java.security.KeyStoreException; 24 | import java.security.NoSuchAlgorithmException; 25 | import java.util.Map; 26 | 27 | public class HttpClientUtil { 28 | 29 | private static HttpClient getClient() throws NoSuchAlgorithmException, 30 | KeyStoreException, KeyManagementException { 31 | SSLContext sslContext = new SSLContextBuilder().loadTrustMaterial(null, 32 | (arg0, arg1) -> true).build(); 33 | SSLConnectionSocketFactory sslConnectionSocketFactory = new 34 | SSLConnectionSocketFactory(sslContext); 35 | CloseableHttpClient client = HttpClients.custom() 36 | .setSSLSocketFactory(sslConnectionSocketFactory) 37 | .build(); 38 | return client; 39 | } 40 | 41 | public static Map postAndGetApiResult(String url, String payload, 42 | String username, String password) throws Exception { 43 | HttpClient client = getClient(); 44 | HttpClientContext context = null; 45 | if (username != null && password != null) { 46 | context = HttpClientContext.create(); 47 | UsernamePasswordCredentials creds = new UsernamePasswordCredentials(username, password); 48 | CredentialsProvider credsProvider = new BasicCredentialsProvider(); 49 | credsProvider.setCredentials(AuthScope.ANY, creds); 50 | context.setCredentialsProvider(credsProvider); 51 | } 52 | 53 | HttpPost httpPost = new HttpPost(url); 54 | httpPost.addHeader("User-Agent", "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/92.0.4515.107 Safari/537.36"); 55 | httpPost.addHeader("Accept", "*/*"); 56 | httpPost.addHeader("Accept-Encoding", "gzip, deflate, br"); 57 | httpPost.addHeader("Content-Type", "application/json"); 58 | httpPost.addHeader("Connection", "keep-alive"); 59 | HttpEntity httpEntity = new StringEntity(payload, StandardCharsets.UTF_8); 60 | httpPost.setEntity(httpEntity); 61 | HttpResponse response = client.execute(httpPost, context); 62 | String data = EntityUtils.toString(response.getEntity()); 63 | return JacksonUtil.jsonToObject(data, Map.class); 64 | 65 | } 66 | 67 | public static String getAndGetApiResult(String url, String username, String password) throws Exception { 68 | HttpClient client = getClient(); 69 | HttpClientContext context = null; 70 | if (username != null && password != null) { 71 | context = HttpClientContext.create(); 72 | UsernamePasswordCredentials creds = new UsernamePasswordCredentials(username, password); 73 | CredentialsProvider credsProvider = new BasicCredentialsProvider(); 74 | credsProvider.setCredentials(AuthScope.ANY, creds); 75 | context.setCredentialsProvider(credsProvider); 76 | } 77 | HttpGet httpGet = new HttpGet(url); 78 | httpGet.addHeader("User-Agent", "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/92.0.4515.107 Safari/537.36"); 79 | httpGet.addHeader("Accept", "*/*"); 80 | httpGet.addHeader("Accept-Encoding", "gzip, deflate, br"); 81 | httpGet.addHeader("Content-Type", "application/json"); 82 | httpGet.addHeader("Connection", "keep-alive"); 83 | HttpResponse response = client.execute(httpGet, context); 84 | String json = EntityUtils.toString(response.getEntity()); 85 | return json; 86 | 87 | } 88 | } 89 | -------------------------------------------------------------------------------- /src/main/java/org/springbus/sd/Main.java: -------------------------------------------------------------------------------- 1 | package org.springbus.sd; 2 | 3 | import org.springbus.sd.extensions.ADetailer; 4 | import org.springbus.sd.extensions.ControlNetUnit; 5 | import org.springbus.sd.model.ControlNet; 6 | import org.springbus.sd.model.PILImage; 7 | import org.springbus.sd.model.Txt2ImgModel; 8 | import org.springbus.sd.model.WebUIApiResult; 9 | import org.springbus.sd.utils.ImageUtil; 10 | 11 | import java.util.List; 12 | 13 | public class Main { 14 | static String baseURL = "http://localhost:7860"; 15 | 16 | static String prompt = "masterpiece, best quality, wall paper, (8k, best quality, masterpiece:1.2),a woman,garden,Sexy, mature woman, wedding dress, smile,happy,flower,look at viewer, full body, "; 17 | static String nsfw = "nsfw,(nipples),leakage points, big boobs, leather, net lining, mesh lining, paintings, big head, sketches, naked, (worst quality:2), (low quality:2), (normal quality:2), lowres, bad anatomy, bad hands, normal quality, ((monochrome)), ((grayscale)), futanari, full-package_futanari, penis_from_girl, newhalf, nipplepierces, glans penis, collapsed eyeshadow, multiple eyeblows, vaginas in breasts, pink hair, holes on breasts, ng_deepnegative_v1_75t, skin spots, acnes, skin blemishes, age spot, glans, nsfw, nipples,extra fingers, ((extra arms)), (extra legs), mutated hands,(fused fingers), (too many fingers), (long neck:1.3)"; 18 | 19 | 20 | static void createText2Img() throws Exception { 21 | WebUIApi webUIApi = new WebUIApi(baseURL); 22 | Txt2ImgModel txt2ImgModel = new Txt2ImgModel(); 23 | txt2ImgModel.prompt = prompt; 24 | txt2ImgModel.negative_prompt = nsfw; 25 | txt2ImgModel.batch_size = 4; 26 | txt2ImgModel.width = 512; 27 | txt2ImgModel.height = 768; 28 | WebUIApiResult r = webUIApi.txt2Img(txt2ImgModel); 29 | List imageList = r.getImages(); 30 | int ix = 0; 31 | for (PILImage image : imageList) { 32 | image.save("./outs/imgs/a-" + ix + ".png"); 33 | ix++; 34 | } 35 | } 36 | 37 | static void crateWithControlNet() throws Exception { 38 | ControlNet net = new ControlNet(); 39 | net.model = "control_v11p_sd15_canny [d14c016b]"; 40 | net.module = "canny"; 41 | net.input_image = ImageUtil.b64Img("./imgs/a.jpeg"); 42 | ControlNetUnit controlNetUnit = new ControlNetUnit(net); 43 | 44 | WebUIApi webUIApi = new WebUIApi(baseURL); 45 | Txt2ImgModel txt2ImgModel = new Txt2ImgModel(); 46 | txt2ImgModel.prompt = prompt; 47 | txt2ImgModel.negative_prompt = nsfw; 48 | txt2ImgModel.batch_size = 4; 49 | txt2ImgModel.width = 512; 50 | txt2ImgModel.height = 768; 51 | txt2ImgModel.withExtensions(controlNetUnit); 52 | WebUIApiResult r = webUIApi.txt2Img(txt2ImgModel); 53 | List imageList = r.getImages(); 54 | int ix = 0; 55 | for (PILImage image : imageList) { 56 | image.save("./outs/imgs/controlnet-" + ix + ".png"); 57 | ix++; 58 | } 59 | } 60 | 61 | static void crateWithADetailer() throws Exception { 62 | ADetailer aDetailer = new ADetailer(); 63 | aDetailer.ad_model = "face_yolov8n.pt"; 64 | WebUIApi webUIApi = new WebUIApi(baseURL); 65 | Txt2ImgModel txt2ImgModel = new Txt2ImgModel(); 66 | txt2ImgModel.prompt = prompt; 67 | txt2ImgModel.negative_prompt = nsfw; 68 | txt2ImgModel.batch_size = 4; 69 | txt2ImgModel.width = 512; 70 | txt2ImgModel.height = 768; 71 | txt2ImgModel.withExtensions(aDetailer); 72 | WebUIApiResult r = webUIApi.txt2Img(txt2ImgModel); 73 | List imageList = r.getImages(); 74 | int ix = 0; 75 | for (PILImage image : imageList) { 76 | image.save("./outs/imgs/aDetailer-" + ix + ".png"); 77 | ix++; 78 | } 79 | 80 | } 81 | 82 | static void getSample() throws Exception { 83 | WebUIApi webUIApi = new WebUIApi(baseURL); 84 | String r = webUIApi.getSamplers(); 85 | System.out.println(r); 86 | } 87 | 88 | static void getLora() throws Exception { 89 | WebUIApi webUIApi = new WebUIApi(baseURL); 90 | String r = webUIApi.getLoras(); 91 | System.out.println(r); 92 | } 93 | 94 | public static void main(String[] args) throws Exception { 95 | // getSample(); 96 | //getLora(); 97 | //crateWithControlNet(); 98 | // crateWithADetailer(); 99 | } 100 | } -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # java sdwebuiapi 2 | JAVA API client for AUTOMATIC1111/stable-diffusion-webui 3 | 4 | Supports txt2img, img2img API calls. 5 | 6 | API support have to be enabled from webui. Add --api when running webui. 7 | It's explained [here](https://github.com/AUTOMATIC1111/stable-diffusion-webui/wiki/API). 8 | 9 | You can use --api-auth user1:pass1,user2:pass2 option to enable authentication for api access. 10 | (Since it's basic http authentication the password is transmitted in cleartext) 11 | 12 | API calls are (almost) direct translation from http://127.0.0.1:7860/docs 13 | 14 | 15 | ## create API client 16 | 17 | ``` 18 | import org.springbus.sd.extensions.ADetailer; 19 | import org.springbus.sd.extensions.ControlNetUnit; 20 | import org.springbus.sd.model.ControlNet; 21 | import org.springbus.sd.model.PILImage; 22 | import org.springbus.sd.model.Txt2ImgModel; 23 | import org.springbus.sd.model.WebUIApiResult; 24 | import org.springbus.sd.utils.ImageUtil; 25 | 26 | import java.util.List; 27 | static String baseURL = "http://localhost:7860"; 28 | 29 | static String prompt = "masterpiece, best quality, wall paper, (8k, best quality, masterpiece:1.2),a woman,garden,Sexy, mature woman, wedding dress, smile,happy,flower,look at viewer, full body, "; 30 | static String nsfw = "nsfw,(nipples),leakage points, big boobs, leather, net lining, mesh lining, paintings, big head, sketches, naked, (worst quality:2), (low quality:2), (normal quality:2), lowres, bad anatomy, bad hands, normal quality, ((monochrome)), ((grayscale)), futanari, full-package_futanari, penis_from_girl, newhalf, nipplepierces, glans penis, collapsed eyeshadow, multiple eyeblows, vaginas in breasts, pink hair, holes on breasts, ng_deepnegative_v1_75t, skin spots, acnes, skin blemishes, age spot, glans, nsfw, nipples,extra fingers, ((extra arms)), (extra legs), mutated hands,(fused fingers), (too many fingers), (long neck:1.3)"; 31 | 32 | 33 | # create API client 34 | WebUIApi webUIApi = new WebUIApi(baseURL); 35 | Txt2ImgModel txt2ImgModel = new Txt2ImgModel(); 36 | txt2ImgModel.prompt = prompt; 37 | txt2ImgModel.negative_prompt = nsfw; 38 | txt2ImgModel.batch_size = 4; 39 | txt2ImgModel.width = 512; 40 | txt2ImgModel.height = 768; 41 | 42 | 43 | # optionally set username, password when --api-auth=username:password is set on webui. 44 | # username, password are not protected and can be derived easily if the communication channel is not encrypted. 45 | # you can also pass username, password to the WebUIApi constructor. 46 | api.setAuth('username', 'password') 47 | ``` 48 | 49 | ## txt2img 50 | ``` 51 | 52 | WebUIApiResult result1 = webUIApi.txt2Img(txt2ImgModel); 53 | 54 | # images contains the returned images (PIL images) 55 | List imageList = result1.getImages(); 56 | 57 | # image is shorthand for images[0] 58 | result1.getImage(); 59 | 60 | # info contains text info about the api call 61 | result1.info 62 | 63 | # info contains paramteres of the api call 64 | result1.parameters 65 | 66 | result1.image 67 | ``` 68 | ![txt2img](./outs/imgs/aDetailer-0.png) 69 | 70 | ## txt2img with control net 71 | ``` 72 | ControlNet net = new ControlNet(); 73 | net.model = "control_v11p_sd15_canny [d14c016b]"; 74 | net.module = "canny"; 75 | net.input_image = ImageUtil.b64Img("./imgs/a.jpeg"); 76 | ControlNetUnit controlNetUnit = new ControlNetUnit(net); 77 | 78 | WebUIApi webUIApi = new WebUIApi(baseURL); 79 | Txt2ImgModel txt2ImgModel = new Txt2ImgModel(); 80 | txt2ImgModel.prompt = prompt; 81 | txt2ImgModel.negative_prompt = nsfw; 82 | txt2ImgModel.batch_size = 4; 83 | txt2ImgModel.width = 512; 84 | txt2ImgModel.height = 768; 85 | txt2ImgModel.withExtensions(controlNetUnit); 86 | WebUIApiResult r = webUIApi.txt2Img(txt2ImgModel); 87 | List imageList = r.getImages(); 88 | int ix = 0; 89 | for (PILImage image : imageList) { 90 | image.save("./outs/imgs/controlnet-" + ix + ".png"); 91 | ix++; 92 | } 93 | ``` 94 | ![txt2img](./outs/imgs/controlnet-1.png) 95 | ![txt2img](./outs/imgs/controlnet-2.png) 96 | 97 | 98 | ## txt2img with ADetailer 99 | ``` 100 | ADetailer aDetailer = new ADetailer(); 101 | aDetailer.ad_model = "face_yolov8n.pt"; 102 | WebUIApi webUIApi = new WebUIApi(baseURL); 103 | Txt2ImgModel txt2ImgModel = new Txt2ImgModel(); 104 | txt2ImgModel.prompt = prompt; 105 | txt2ImgModel.negative_prompt = nsfw; 106 | txt2ImgModel.batch_size = 4; 107 | txt2ImgModel.width = 512; 108 | txt2ImgModel.height = 768; 109 | txt2ImgModel.withExtensions(aDetailer); 110 | WebUIApiResult r = webUIApi.txt2Img(txt2ImgModel); 111 | List imageList = r.getImages(); 112 | int ix = 0; 113 | for (PILImage image : imageList) { 114 | image.save("./outs/imgs/aDetailer-" + ix + ".png"); 115 | ix++; 116 | } 117 | ``` 118 | ![txt2img](./outs/imgs/aDetailer-0.png) 119 | ![txt2img](./outs/imgs/aDetailer-2.png) 120 | 121 | ### Configuration APIs 122 | ``` 123 | # get available sd models 124 | api.getSdModels() 125 | 126 | # misc get apis 127 | api.getSamplers() 128 | api.getCmdFlags() 129 | api.getHypernetworks() 130 | api.getFaceRestorers() 131 | api.getRealesrganModels() 132 | api.getPromptStyles() 133 | api.getArtistCategories() # deprecated ? 134 | api.getArtists() # deprecated ? 135 | api.getProgress() 136 | api.getEmbeddings() 137 | api.getCmdFlags() 138 | api.getScripts() 139 | api.getMemory() 140 | 141 | # misc apis 142 | api.interrupt() 143 | api.skip() 144 | ``` 145 | 146 | 147 | 148 | -------------------------------------------------------------------------------- /src/main/java/org/springbus/sd/WebUIApi.java: -------------------------------------------------------------------------------- 1 | package org.springbus.sd; 2 | 3 | import org.springbus.sd.model.Img2ImgModel; 4 | import org.springbus.sd.model.Txt2ImgModel; 5 | import org.springbus.sd.model.WebUIApiResult; 6 | import org.springbus.sd.utils.HttpClientUtil; 7 | import org.springbus.sd.utils.JacksonUtil; 8 | 9 | import java.util.List; 10 | import java.util.Map; 11 | 12 | public class WebUIApi { 13 | private String baseurl = "http://localhost:7660"; 14 | 15 | private String userName; 16 | private String passWord; 17 | 18 | 19 | public WebUIApi(String baseurl) { 20 | this.baseurl = baseurl + "/sdapi/v1"; 21 | } 22 | 23 | public WebUIApi() { 24 | this.baseurl = baseurl + "/sdapi/v1"; 25 | } 26 | 27 | public void setAuth(String userName, String passWord) { 28 | this.userName = userName; 29 | this.passWord = passWord; 30 | } 31 | 32 | 33 | public WebUIApiResult txt2Img(Txt2ImgModel txt2ImgModel) throws Exception { 34 | String url = baseurl + "/txt2img"; 35 | String payload = JacksonUtil.toJsonString(txt2ImgModel); 36 | System.out.println(payload); 37 | Map result = HttpClientUtil.postAndGetApiResult(url, payload, userName, passWord); 38 | return toApiResult(result); 39 | } 40 | public WebUIApiResult img2Img(Img2ImgModel img2ImgModel) throws Exception { 41 | String url = baseurl + "/img2img"; 42 | String payload = JacksonUtil.toJsonString(img2ImgModel); 43 | Map result = HttpClientUtil.postAndGetApiResult(url, payload, userName, passWord); 44 | return toApiResult(result); 45 | } 46 | 47 | 48 | private WebUIApiResult toApiResult(Map result) { 49 | Object o = result.get("images"); 50 | WebUIApiResult rs = new WebUIApiResult(); 51 | if (o == null) { 52 | o = result.get("image"); 53 | } 54 | if (o != null && o instanceof List) { 55 | List imgs = (List) o; 56 | for (String img : imgs) { 57 | rs.addImage(img); 58 | } 59 | } 60 | Object info = result.get("info"); 61 | if (info instanceof String) { 62 | rs.info.putAll(JacksonUtil.jsonToObject(String.valueOf(info), Map.class)); 63 | } 64 | 65 | Object parameters = result.get("parameters"); 66 | if (parameters != null) { 67 | if (parameters instanceof String) { 68 | rs.parameters.putAll(JacksonUtil.jsonToObject(String.valueOf(parameters), Map.class)); 69 | } else if (parameters instanceof Map) { 70 | rs.parameters.putAll((Map) parameters); 71 | } 72 | } 73 | return rs; 74 | } 75 | 76 | 77 | public WebUIApiResult pngInfo(String image) throws Exception { 78 | String payload = "{\"image\":" + "\"" + image + "\" }"; 79 | 80 | String url = baseurl + "/png-info"; 81 | Map result = HttpClientUtil.postAndGetApiResult(url, payload, userName, passWord); 82 | return toApiResult(result); 83 | } 84 | 85 | /** 86 | * param model "clip" or "deepdanbooru" 87 | */ 88 | public WebUIApiResult interrogate(String image, String model) throws Exception { 89 | String payload = " {\"image\":\"" + image + "\", \"model\": " + model + "\"} "; 90 | String url = baseurl + "/interrogate"; 91 | Map result = HttpClientUtil.postAndGetApiResult(url, payload, userName, passWord); 92 | return toApiResult(result); 93 | } 94 | 95 | public String interrupt() throws Exception { 96 | String url = baseurl + "/interrupt"; 97 | return HttpClientUtil.getAndGetApiResult(url, userName, passWord); 98 | } 99 | 100 | 101 | public String skip() throws Exception { 102 | String url = baseurl + "/skip"; 103 | return HttpClientUtil.getAndGetApiResult(url, userName, passWord); 104 | } 105 | 106 | 107 | public String getOptions() throws Exception { 108 | String url = baseurl + "/options"; 109 | return HttpClientUtil.getAndGetApiResult(url, userName, passWord); 110 | } 111 | 112 | public Map setOptions(Map options) throws Exception { 113 | String url = baseurl + "/options"; 114 | String payload = JacksonUtil.toJsonString(options); 115 | return HttpClientUtil.postAndGetApiResult(url, payload, userName, passWord); 116 | } 117 | 118 | 119 | public String getCmdFlags() throws Exception { 120 | String url = baseurl + "/cmd-flags"; 121 | return HttpClientUtil.getAndGetApiResult(url, userName, passWord); 122 | } 123 | 124 | public String getProgress() throws Exception { 125 | String url = baseurl + "/progress"; 126 | return HttpClientUtil.getAndGetApiResult(url, userName, passWord); 127 | } 128 | 129 | public String getSamplers() throws Exception { 130 | String url = baseurl + "/samplers"; 131 | return HttpClientUtil.getAndGetApiResult(url, userName, passWord); 132 | } 133 | 134 | public String getSdVae() throws Exception { 135 | String url = baseurl + "/sd-vae"; 136 | return HttpClientUtil.getAndGetApiResult(url, userName, passWord); 137 | } 138 | 139 | public String getUpscalers() throws Exception { 140 | String url = baseurl + "/upscalers"; 141 | return HttpClientUtil.getAndGetApiResult(url, userName, passWord); 142 | } 143 | 144 | public String getLatentUpscaleModes() throws Exception { 145 | String url = baseurl + "/latent-upscale-modes"; 146 | return HttpClientUtil.getAndGetApiResult(url, userName, passWord); 147 | } 148 | 149 | public String getLoras() throws Exception { 150 | String url = baseurl + "/loras"; 151 | return HttpClientUtil.getAndGetApiResult(url, userName, passWord); 152 | } 153 | 154 | public String getSdModels() throws Exception { 155 | String url = baseurl + "/sd-models"; 156 | return HttpClientUtil.getAndGetApiResult(url, userName, passWord); 157 | } 158 | 159 | public String getHypernetworks() throws Exception { 160 | String url = baseurl + "/hypernetwork"; 161 | return HttpClientUtil.getAndGetApiResult(url, userName, passWord); 162 | } 163 | 164 | public String getFaceRestorers() throws Exception { 165 | String url = baseurl + "/face-restorers"; 166 | return HttpClientUtil.getAndGetApiResult(url, userName, passWord); 167 | } 168 | 169 | public String getRealesrganModels() throws Exception { 170 | String url = baseurl + "/realesrgan-models"; 171 | return HttpClientUtil.getAndGetApiResult(url, userName, passWord); 172 | } 173 | 174 | public String getPromptStyles() throws Exception { 175 | String url = baseurl + "/prompt-styles"; 176 | String payload = "{}"; 177 | return HttpClientUtil.getAndGetApiResult(url, userName, passWord); 178 | } 179 | 180 | public String getArtistCategories() throws Exception { 181 | String url = baseurl + "/artist-categories"; 182 | return HttpClientUtil.getAndGetApiResult(url, userName, passWord); 183 | } 184 | 185 | public String getArtists() throws Exception { 186 | String url = baseurl + "/artists"; 187 | return HttpClientUtil.getAndGetApiResult(url, userName, passWord); 188 | } 189 | 190 | public String refreshCheckpoints() throws Exception { 191 | String url = baseurl + "/refresh-checkpoints"; 192 | return HttpClientUtil.getAndGetApiResult(url, userName, passWord); 193 | } 194 | 195 | public String getScripts() throws Exception { 196 | String url = baseurl + "/scripts"; 197 | return HttpClientUtil.getAndGetApiResult(url, userName, passWord); 198 | } 199 | 200 | public String getEmbeddings() throws Exception { 201 | String url = baseurl + "/embeddings"; 202 | return HttpClientUtil.getAndGetApiResult(url, userName, passWord); 203 | } 204 | 205 | public String getMemory() throws Exception { 206 | String url = baseurl + "/memory"; 207 | return HttpClientUtil.getAndGetApiResult(url, userName, passWord); 208 | } 209 | 210 | } 211 | --------------------------------------------------------------------------------