33 lines
1.2 KiB
Python
33 lines
1.2 KiB
Python
import requests
|
|
def get_sd_model():
|
|
url = "http://192.168.2.157:7860/sdapi/v1/sd-models"
|
|
response = requests.get(url)
|
|
if response.status_code == 200:
|
|
print("Request was successful.")
|
|
print("Response:")
|
|
print(response.json())
|
|
|
|
|
|
def get_current_options():
|
|
response = requests.get(f"http://192.168.2.157:7860/sdapi/v1/options")
|
|
if response.status_code == 200:
|
|
print(response.json())
|
|
return response.json()
|
|
else:
|
|
print(f"Failed to get options with status code {response.status_code}")
|
|
return None
|
|
|
|
def set_new_checkpoint(checkpoint_name):
|
|
options = get_current_options()
|
|
if options is not None:
|
|
options['sd_model_checkpoint'] = checkpoint_name
|
|
response = requests.post(f"http://192.168.2.157:7860/sdapi/v1/options", json=options)
|
|
if response.status_code == 200:
|
|
print(f"Successfully set new checkpoint to {checkpoint_name}")
|
|
else:
|
|
print(f"Failed to set new checkpoint with status code {response.status_code}")
|
|
print("Response:", response.text)
|
|
|
|
get_current_options()
|
|
set_new_checkpoint("dreamshaper_8.safetensors [879db523c3]")
|
|
get_current_options() |