Downloads · 30 days
0
bharat154b/123
123 is a machine learning model from bharat154b. Use it for the machine learning task on the model card, and read the license before you ship it in a product.
pip install Pillow from PIL import Image, ImageDraw, ImageFont
Downloads · 30 days
0
Access
Public
Updated Jan 4, 2024
Repo size
—
Likes
0
Public
Click a slice to open those files.
Other1.5 KB · 69%
From the Hugging Face model README
pip install Pillow from PIL import Image, ImageDraw, ImageFont
def text_to_image(text, output_path='output_image.png', font_size=20): # Create a blank image with white background image = Image.new('RGB', (500, 100), color='white') draw = ImageDraw.Draw(image)
# Choose a font
font = ImageFont.load_default()
# Set text color
text_color = 'black'
# Set starting position for the text
x, y = 10, 10
# Draw the text on the image
draw.text((x, y), text, font=font, fill=text_color)
# Save the image
image.save(output_path)
if name == "main": # Example usage input_text = "Hello, Hugging Face!" text_to_image(input_text)