Creating a picture through the API - Create Image - Endpoint 30 - does not work - Help? #1507
Unanswered
miraculix95
asked this question in
Q&A
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
Hi everyone, I am just trying to use the API as described in the footnotes. As it seems most endpoints, or numbers are useless.
Is there a more detailed explanation.
However the endpoint 30 seems to be used to create pictures. However I have not been able to make it work in Python.
I have installted gradio_client with pip install.
The interpreter is running (I am using google colab) is running for up to a minute then there is an error.
Does anyone havea working example?
it says "loaded as API" then there is a mistake. See below.
my code
`from gradio_client import Client
client = Client("https://e1e966928d694b94fa.gradio.live/")
result = client.predict(
"A man in a boat on a river", # str in 'parameter_10' Textbox component
"", # str in 'Negative Prompt' Textbox component
["Fooocus V2"], # List[str] in 'Selected Styles' Checkboxgroup component
"Speed", # str in 'Performance' Radio component
"704×1408 ∣ 1:2", # str in 'Aspect Ratios' Radio component
1, # int | float (numeric value between 1 and 32) in 'Image Number' Slider component
"6767620991018717316", # str in 'Seed' Textbox component
0, # int | float (numeric value between 0.0 and 30.0) in 'Image Sharpness' Slider component
1, # int | float (numeric value between 1.0 and 30.0) in 'Guidance Scale' Slider component
"pyrosNSFWSDXL_v04.safetensors", # str (Option from: ['pyrosNSFWSDXL_v04.safetensors', 'afroditeXL_11Bkdvae.safetensors', 'xl13AsmodeusSFWNSFW_v22BakedVAE.safetensors', 'juggernautXL_version6Rundiffusion.safetensors', 'realisticStockPhoto_v10.safetensors']) in 'Base Model (SDXL only)' Dropdown component
"None", # str (Option from: ['None', 'pyrosNSFWSDXL_v04.safetensors', 'afroditeXL_11Bkdvae.safetensors', 'xl13AsmodeusSFWNSFW_v22BakedVAE.safetensors', 'juggernautXL_version6Rundiffusion.safetensors', 'realisticStockPhoto_v10.safetensors']) in 'Refiner (SDXL or SD 1.5)' Dropdown component
0.1, # int | float (numeric value between 0.1 and 1.0) in 'Refiner Switch At' Slider component
"None", # str (Option from: ['None', 'SDXL_Sevenof9_5th_NSFW_32.safetensors', 'nsfw-xl-2.0.safetensors', 'NsfwPovAllInOneLoraSdxl-000009MINI.safetensors', 'sd_xl_offset_example-lora_1.0.safetensors', 'SDXL_FILM_PHOTOGRAPHY_STYLE_BetaV0.4.safetensors']) in 'LoRA 1' Dropdown component
-2, # int | float (numeric value between -2 and 2) in 'Weight' Slider component
"None", # str (Option from: ['None', 'SDXL_Sevenof9_5th_NSFW_32.safetensors', 'nsfw-xl-2.0.safetensors', 'NsfwPovAllInOneLoraSdxl-000009MINI.safetensors', 'sd_xl_offset_example-lora_1.0.safetensors', 'SDXL_FILM_PHOTOGRAPHY_STYLE_BetaV0.4.safetensors']) in 'LoRA 2' Dropdown component
-2, # int | float (numeric value between -2 and 2) in 'Weight' Slider component
"None", # str (Option from: ['None', 'SDXL_Sevenof9_5th_NSFW_32.safetensors', 'nsfw-xl-2.0.safetensors', 'NsfwPovAllInOneLoraSdxl-000009MINI.safetensors', 'sd_xl_offset_example-lora_1.0.safetensors', 'SDXL_FILM_PHOTOGRAPHY_STYLE_BetaV0.4.safetensors']) in 'LoRA 3' Dropdown component
-2, # int | float (numeric value between -2 and 2) in 'Weight' Slider component
"None", # str (Option from: ['None', 'SDXL_Sevenof9_5th_NSFW_32.safetensors', 'nsfw-xl-2.0.safetensors', 'NsfwPovAllInOneLoraSdxl-000009MINI.safetensors', 'sd_xl_offset_example-lora_1.0.safetensors', 'SDXL_FILM_PHOTOGRAPHY_STYLE_BetaV0.4.safetensors']) in 'LoRA 4' Dropdown component
-2, # int | float (numeric value between -2 and 2) in 'Weight' Slider component
"None", # str (Option from: ['None', 'SDXL_Sevenof9_5th_NSFW_32.safetensors', 'nsfw-xl-2.0.safetensors', 'NsfwPovAllInOneLoraSdxl-000009MINI.safetensors', 'sd_xl_offset_example-lora_1.0.safetensors', 'SDXL_FILM_PHOTOGRAPHY_STYLE_BetaV0.4.safetensors']) in 'LoRA 5' Dropdown component
-2, # int | float (numeric value between -2 and 2) in 'Weight' Slider component
False, # bool in 'Input Image' Checkbox component
"", # str in 'parameter_82' Textbox component
"Disabled", # str in 'Upscale or Variation:' Radio component
"", # str (filepath or URL to image) in 'Drag above image to here' Image component
["Left"], # List[str] in 'Outpaint Direction' Checkboxgroup component
"", # str (filepath or URL to image) in 'Drag above image to here' Image component
"", # str in 'Inpaint Additional Prompt' Textbox component
"", # str (filepath or URL to image) in 'Image' Image component
0, # int | float (numeric value between 0.0 and 1.0) in 'Stop At' Slider component
0, # int | float (numeric value between 0.0 and 2.0) in 'Weight' Slider component
"", # str in 'Type' Radio component
"", # str (filepath or URL to image) in 'Image' Image component
0, # int | float (numeric value between 0.0 and 1.0) in 'Stop At' Slider component
0, # int | float (numeric value between 0.0 and 2.0) in 'Weight' Slider component
"", # str in 'Type' Radio component
"", # str (filepath or URL to image) in 'Image' Image component
0, # int | float (numeric value between 0.0 and 1.0) in 'Stop At' Slider component
0, # int | float (numeric value between 0.0 and 2.0) in 'Weight' Slider component
"", # str in 'Type' Radio component
"", # str (filepath or URL to image) in 'Image' Image component
0, # int | float (numeric value between 0.0 and 1.0) in 'Stop At' Slider component
0, # int | float (numeric value between 0.0 and 2.0) in 'Weight' Slider component
"", # str in 'Type' Radio component
fn_index = 30
)
print(result)`
the error
AttributeError Traceback (most recent call last)
in <cell line: 4>()
2
3 client = Client("https://e1e966928d694b94fa.gradio.live/")
----> 4 result = client.predict(
5 "A man in a boat on a river", # str in 'parameter_10' Textbox component
6 "", # str in 'Negative Prompt' Textbox component
12 frames
/usr/local/lib/python3.10/dist-packages/gradio_client/client.py in predict(self, api_name, fn_index, *args)
390 "Cannot call predict on this function as it may run forever. Use submit instead."
391 )
--> 392 return self.submit(*args, api_name=api_name, fn_index=fn_index).result()
393
394 def new_helper(self, fn_index: int) -> Communicator:
/usr/local/lib/python3.10/dist-packages/gradio_client/client.py in result(self, timeout)
1563 >> 9
1564 """
-> 1565 return super().result(timeout=timeout)
1566
1567 def outputs(self) -> list[tuple | Any]:
/usr/lib/python3.10/concurrent/futures/_base.py in result(self, timeout)
456 raise CancelledError()
457 elif self._state == FINISHED:
--> 458 return self.__get_result()
459 else:
460 raise TimeoutError()
/usr/lib/python3.10/concurrent/futures/_base.py in __get_result(self)
401 if self._exception:
402 try:
--> 403 raise self._exception
404 finally:
405 # Break a reference cycle with the exception in self._exception
/usr/lib/python3.10/concurrent/futures/thread.py in run(self)
56
57 try:
---> 58 result = self.fn(*self.args, **self.kwargs)
59 except BaseException as exc:
60 self.future.set_exception(exc)
/usr/local/lib/python3.10/dist-packages/gradio_client/client.py in _inner(*data)
1236 data = self.serialize(*data)
1237 predictions = _predict(*data)
-> 1238 predictions = self.process_predictions(*predictions)
1239 # Append final output only if not already present
1240 # for consistency between generators and not generators
/usr/local/lib/python3.10/dist-packages/gradio_client/client.py in process_predictions(self, *predictions)
1425 def process_predictions(self, *predictions):
1426 if self.client.serialize:
-> 1427 predictions = self.deserialize(*predictions)
1428 predictions = self.remove_skipped_components(*predictions)
1429 predictions = self.reduce_singleton_output(*predictions)
/usr/local/lib/python3.10/dist-packages/gradio_client/client.py in deserialize(self, *data)
1411 )
1412 outputs = tuple(
-> 1413 [
1414 s.deserialize(
1415 d,
/usr/local/lib/python3.10/dist-packages/gradio_client/client.py in (.0)
1412 outputs = tuple(
1413 [
-> 1414 s.deserialize(
1415 d,
1416 save_dir=self.client.output_dir,
/usr/local/lib/python3.10/dist-packages/gradio_client/serializing.py in deserialize(self, x, save_dir, root_url, hf_token)
205 if x is None or x == "":
206 return None
--> 207 file = utils.decode_base64_to_file(x, dir=save_dir)
208 return file.name
209
/usr/local/lib/python3.10/dist-packages/gradio_client/utils.py in decode_base64_to_file(encoding, file_path, dir, prefix)
716 directory = Path(dir or tempfile.gettempdir()) / secrets.token_hex(20)
717 directory.mkdir(exist_ok=True, parents=True)
--> 718 data, extension = decode_base64_to_binary(encoding)
719 if file_path is not None and prefix is None:
720 filename = Path(file_path).name
/usr/local/lib/python3.10/dist-packages/gradio_client/utils.py in decode_base64_to_binary(encoding)
681
682 def decode_base64_to_binary(encoding: str) -> tuple[bytes, str | None]:
--> 683 extension = get_extension(encoding)
684 data = encoding.rsplit(",", 1)[-1]
685 return base64.b64decode(data), extension
/usr/local/lib/python3.10/dist-packages/gradio_client/utils.py in get_extension(encoding)
627
628 def get_extension(encoding: str) -> str | None:
--> 629 encoding = encoding.replace("audio/wav", "audio/x-wav")
630 type = mimetypes.guess_type(encoding)[0]
631 if type == "audio/flac": # flac is not supported by mimetypes
AttributeError: 'dict' object has no attribute 'replace'
Beta Was this translation helpful? Give feedback.
All reactions