-
Notifications
You must be signed in to change notification settings - Fork 88
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
15 changed files
with
188 additions
and
186 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
79 changes: 0 additions & 79 deletions
79
lib/gpt_providers/image_to_text_gen/gemini_image_details.py
This file was deleted.
Oops, something went wrong.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
41 changes: 41 additions & 0 deletions
41
lib/gpt_providers/text_to_image_generation/gen_stabl_diff_img.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
from PIL import Image | ||
import requests | ||
|
||
# Ensure you sign up for an account to obtain an API key: | ||
# https://platform.stability.ai/ | ||
# Your API key can be found here after account creation: | ||
# https://platform.stability.ai/account/keys | ||
|
||
|
||
def generate_stable_diffusion_image(prompt): | ||
""" | ||
Generate images using Stable Diffusion API based on a given prompt. | ||
Args: | ||
prompt (str): The prompt to generate the image. | ||
image_dir (str): The directory where the image will be saved. | ||
Raises: | ||
Warning: If the adult content classifier is triggered. | ||
Exception: For any issues during image generation or saving. | ||
""" | ||
api_key = os.getenv('STABILITY_API_KEY') | ||
|
||
response = requests.post( | ||
f"https://api.stability.ai/v2beta/stable-image/generate/sd3", | ||
headers={ | ||
"authorization": f"Bearer {api_key}", | ||
"accept": "image/*" | ||
}, | ||
files={"none": ''}, | ||
data={ | ||
"prompt": prompt, | ||
"output_format": "webp", | ||
}, | ||
) | ||
|
||
if response.status_code == 200: | ||
with open("./dog-wearing-glasses.jpeg", 'wb') as file: | ||
file.write(response.content) | ||
else: | ||
raise Exception(str(response.json())) |
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
Oops, something went wrong.