20+ LLM's that Generate Images

We review and show installation instructions for the top 20+ LLMs at huggingface.com

20+ LLM's that Generate Images

Image Generation Models and Meme Conversion Tools

The following table compiles the requested information based on a comprehensive review of available resources. For image generation models from Hugging Face (part 1), I have identified prominent text-to-image models, sorted into two categories: those primarily optimized for or defaulting to square image generation (e.g., fixed resolutions like 512x512 or 1024x1024, with limited explicit support for varying aspect ratios in their documentation), and those that explicitly support or perform well with non-square aspect ratios (e.g., vertical, horizontal, or custom dimensions). Note that many models can technically generate non-square images through pipeline adjustments, but categorization is based on model card descriptions and reported capabilities.

For meme conversion tools (part 2), I have included programming libraries and scripts (primarily Python-based, with some Bash options) that enable automatic image-to-meme conversion, such as adding text overlays, captions, or effects via scripts. These are listed in a separate section of the table.

The table includes:

  • Name: The model or tool name.
  • Type: Image Generation (Square-Optimized or Aspect Ratio-Supported) or Meme Conversion Tool.
  • Description/Capabilities: Brief overview, including resolution support where applicable.
  • Install Instructions: For models, instructions assume use with the Hugging Face Diffusers library; for tools, package installation commands.
  • Link: Direct link to the model card, repository, or documentation.
Name Type Description/Capabilities Install Instructions Link
stabilityai/sd-turbo Image Generation (Square-Optimized) A distilled version of Stable Diffusion 2.1, optimized for fast generation at 512x512 resolution. Primarily square-focused but can be adapted. pip install diffusers transformers; then use: from diffusers import DiffusionPipeline; pipe = DiffusionPipeline.from_pretrained("stabilityai/sd-turbo") https://huggingface.co/stabilityai/sd-turbo
runwayml/stable-diffusion-v1-5 Image Generation (Square-Optimized) Fine-tuned Stable Diffusion model for text-to-image, defaulting to 512x512 square outputs. pip install diffusers transformers; then use: from diffusers import DiffusionPipeline; pipe = DiffusionPipeline.from_pretrained("runwayml/stable-diffusion-v1-5") https://huggingface.co/runwayml/stable-diffusion-v1-5
CompVis/stable-diffusion-v1-4 Image Generation (Square-Optimized) Early Stable Diffusion variant, trained on square 512x512 images. pip install diffusers transformers; then use: from diffusers import DiffusionPipeline; pipe = DiffusionPipeline.from_pretrained("CompVis/stable-diffusion-v1-4") https://huggingface.co/CompVis/stable-diffusion-v1-4
stabilityai/stable-diffusion-2-1 Image Generation (Square-Optimized) Improved Stable Diffusion model with default 768x768 square resolution. pip install diffusers transformers; then use: from diffusers import DiffusionPipeline; pipe = DiffusionPipeline.from_pretrained("stabilityai/stable-diffusion-2-1") https://huggingface.co/stabilityai/stable-diffusion-2-1
dalle-mini/dalle-mini Image Generation (Square-Optimized) Mini version of DALL-E, generating 256x256 square images. pip install diffusers transformers; then use: from diffusers import DiffusionPipeline; pipe = DiffusionPipeline.from_pretrained("dalle-mini/dalle-mini") https://huggingface.co/dalle-mini/dalle-mini
stabilityai/stable-diffusion-xl-base-1.0 Image Generation (Aspect Ratio-Supported) Advanced Stable Diffusion XL model supporting various resolutions, including non-square aspect ratios like 1024x768. pip install diffusers transformers; then use: from diffusers import DiffusionPipeline; pipe = DiffusionPipeline.from_pretrained("stabilityai/stable-diffusion-xl-base-1.0") https://huggingface.co/stabilityai/stable-diffusion-xl-base-1.0
black-forest-labs/FLUX.1-dev Image Generation (Aspect Ratio-Supported) High-performance model from Black Forest Labs, capable of custom aspect ratios beyond square defaults. pip install diffusers transformers; then use: from diffusers import DiffusionPipeline; pipe = DiffusionPipeline.from_pretrained("black-forest-labs/FLUX.1-dev") https://huggingface.co/black-forest-labs/FLUX.1-dev
dreamlike-art/dreamlike-photoreal-2.0 Image Generation (Aspect Ratio-Supported) Photorealistic model that explicitly supports non-square aspect ratios, such as 2:3 for portraits or 3:2 for landscapes. pip install diffusers transformers; then use: from diffusers import DiffusionPipeline; pipe = DiffusionPipeline.from_pretrained("dreamlike-art/dreamlike-photoreal-2.0") https://huggingface.co/dreamlike-art/dreamlike-photoreal-2.0
dreamlike-art/dreamlike-diffusion-1.0 Image Generation (Aspect Ratio-Supported) Diffusion model fine-tuned for better non-square outputs, including vertical and horizontal aspects. pip install diffusers transformers; then use: from diffusers import DiffusionPipeline; pipe = DiffusionPipeline.from_pretrained("dreamlike-art/dreamlike-diffusion-1.0") https://huggingface.co/dreamlike-art/dreamlike-diffusion-1.0
stabilityai/deepfloyd-if Image Generation (Aspect Ratio-Supported) Cascaded pixel diffusion model supporting non-standard aspect ratios, including vertical and horizontal. pip install diffusers transformers; then use: from diffusers import DiffusionPipeline; pipe = DiffusionPipeline.from_pretrained("stabilityai/deepfloyd-if") https://huggingface.co/DeepFloyd/IF-I-XL-v1.0 (related model card)
ttj/flex-diffusion-2-1 Image Generation (Aspect Ratio-Supported) Flexible diffusion model trained on multiple aspect ratios, supporting non-square resolutions. pip install diffusers transformers; then use: from diffusers import DiffusionPipeline; pipe = DiffusionPipeline.from_pretrained("ttj/flex-diffusion-2-1") https://huggingface.co/ttj/flex-diffusion-2-1
recraft-ai/recraft-v3 Image Generation (Aspect Ratio-Supported) Top-ranked model on leaderboards, supporting diverse aspect ratios for high-quality outputs. pip install diffusers transformers; then use: from diffusers import DiffusionPipeline; pipe = DiffusionPipeline.from_pretrained("recraft-ai/recraft-v3") https://huggingface.co/recraft-ai/recraft-v3
black-forest-labs/FLUX.1.1-pro Image Generation (Aspect Ratio-Supported) Professional variant of FLUX, designed for variable aspect ratios in image generation. pip install diffusers transformers; then use: from diffusers import DiffusionPipeline; pipe = DiffusionPipeline.from_pretrained("black-forest-labs/FLUX.1.1-pro") https://huggingface.co/black-forest-labs/FLUX.1-schnell (related variant)
MemePy Meme Conversion Tool Python library for editing meme templates by adding text to images automatically. pip install MemePy https://pypi.org/project/MemePy/
minimaxir/imgmaker Meme Conversion Tool Python package for generating images with text, watermarks, or meme-style overlays programmatically. pip install git+https://github.com/minimaxir/imgmaker.git https://github.com/minimaxir/imgmaker
ImageMagick Meme Conversion Tool Command-line tool (usable in Bash scripts) for image processing, including adding text to convert images to memes. Install via package manager: apt install imagemagick (Ubuntu) or brew install imagemagick (macOS); use in script: convert input.jpg -pointsize 30 -fill white -annotate +10+30 'Top Text' -annotate +10+ (height-10) 'Bottom Text' output.jpg https://imagemagick.org/script/convert.php
Imgflip API Script Meme Conversion Tool Bash script using Imgflip API to generate memes from images via curl commands. No install needed; use curl in Bash: curl -s 'https://api.imgflip.com/caption_image?template_id=ID&username=USER&password=PASS&text0=Top&text1=Bottom' https://github.com/swillner/imgflip-meme (example script)
Taipy GUI Meme Generator Meme Conversion Tool Python web app for custom meme generation, adaptable to scripts for automatic conversion. pip install taipy https://dev.to/jr_shittu/python-day-10-meme-magic-building-a-custom-meme-generator-with-python-2ejc
AI-Memer System Meme Conversion Tool Python-based system using machine learning to find backgrounds, generate captions, and typeset memes automatically. Requires custom setup with libraries like Pillow and caption models; pip install pillow transformers https://thenextweb.com/news/how-to-build-your-own-meme-generator-with-machine-learning
HuggingFaceM4/AI_Meme_Generator Meme Conversion Tool Hugging Face Space for AI-driven meme generation from uploaded images; can be scripted via API. pip install huggingface_hub; use API endpoint for scripting https://huggingface.co/spaces/HuggingFaceM4/AI_Meme_Generator
bickett/meme-llama Meme Conversion Tool Fine-tuned Llama model on Hugging Face for generating meme captions, integrable with Python image tools for full automation. pip install transformers; then use: from transformers import pipeline; generator = pipeline('text-generation', model='bickett/meme-llama') https://huggingface.co/bickett/meme-llama

Installation Instructions for Each One:

Image Generation Models (Square-Optimized)

stabilityai/sd-turbo

Installation Instructions

To utilize the SD-Turbo model with the Diffusers library, execute the following command to install the necessary packages:

pip install diffusers transformers accelerate --upgrade

No authentication is required for loading the model from the Hugging Face repository.

Example Code

The following Python code snippet demonstrates text-to-image generation with SD-Turbo, producing a 512x512 square image in a single inference step. Note that SD-Turbo does not support guidance scale or negative prompts.

from diffusers import AutoPipelineForText2Image
import torch

pipe = AutoPipelineForText2Image.from_pretrained("stabilityai/sd-turbo", torch_dtype=torch.float16, variant="fp16")
pipe.to("cuda")

prompt = "A cinematic shot of a baby racoon wearing an intricate italian priest robe."
image = pipe(prompt=prompt, num_inference_steps=1, guidance_scale=0.0).images[0]
image.save("generated_image.png")

runwayml/stable-diffusion-v1-5

Installation Instructions

To employ the Stable Diffusion v1-5 model with the Diffusers library, install the required packages using the command:

pip install diffusers transformers scipy

No authentication is necessary for accessing the model from Hugging Face. For GPU utilization, ensure a CUDA-enabled device is available.

Example Code

The following Python code snippet illustrates text-to-image generation, yielding a 512x512 square image. It employs float16 precision for memory efficiency.

import torch
from diffusers import StableDiffusionPipeline

model_id = "runwayml/stable-diffusion-v1-5"
pipe = StableDiffusionPipeline.from_pretrained(model_id, torch_dtype=torch.float16)
pipe = pipe.to("cuda")

prompt = "A red square on a white background"
image = pipe(prompt).images[0]
image.save("generated_square.png")

CompVis/stable-diffusion-v1-4

Installation Instructions

For the Stable Diffusion v1-4 model with the Diffusers library, install the essential packages via:

pip install --upgrade diffusers transformers scipy

No authentication is required. A CUDA-enabled GPU is recommended; for limited memory, use float16 precision and enable attention slicing.

Example Code

The following Python code snippet facilitates text-to-image generation, creating a 512x512 square image.

import torch
from diffusers import StableDiffusionPipeline

model_id = "CompVis/stable-diffusion-v1-4"
device = "cuda"

pipe = StableDiffusionPipeline.from_pretrained(model_id, torch_dtype=torch.float16)
pipe = pipe.to(device)
pipe.enable_attention_slicing()

prompt = "a red square on a white background"
image = pipe(prompt).images[0]  
image.save("generated_square.png")

stabilityai/stable-diffusion-2-1

Installation Instructions

To access the Stable Diffusion v2-1 model with the Diffusers library, install the following packages:

pip install diffusers transformers accelerate scipy safetensors

No authentication is needed. Installation of xformers is recommended for enhanced performance, though optional.

Example Code

The following Python code snippet demonstrates text-to-image generation, producing a square image (default 512x512) using the DPMSolverMultistepScheduler.

import torch
from diffusers import StableDiffusionPipeline, DPMSolverMultistepScheduler

model_id = "stabilityai/stable-diffusion-2-1"
pipe = StableDiffusionPipeline.from_pretrained(model_id, torch_dtype=torch.float16)
pipe.scheduler = DPMSolverMultistepScheduler.from_config(pipe.scheduler.config)
pipe = pipe.to("cuda")

prompt = "a red square on a white background"
image = pipe(prompt).images[0]
image.save("square_image.png")

dalle-mini/dalle-mini

Installation Instructions

For the DALL-E Mini model with the Diffusers library, install the required packages using:

pip install diffusers transformers

No authentication is specified. Refer to the GitHub repository (https://github.com/borisdayma/dalle-mini) for additional setup details if needed.

Example Code

The following Python code snippet enables text-to-image generation, resulting in a 256x256 square image.

from diffusers import DiffusionPipeline
import torch

pipe = DiffusionPipeline.from_pretrained("dalle-mini/dalle-mini", torch_dtype=torch.float16)
pipe = pipe.to("cuda")

prompt = "A scenic landscape"
image = pipe(prompt).images[0]
image.save("generated_image.png")

Image Generation Models (Aspect Ratio-Supported)

stabilityai/stable-diffusion-xl-base-1.0

Installation Instructions

To use the Stable Diffusion XL base model with the Diffusers library (version >= 0.19.0), install the packages as follows:

pip install diffusers --upgrade
pip install invisible_watermark transformers accelerate safetensors

No authentication is required.

Example Code

The following Python code snippet generates an image with a custom aspect ratio (e.g., 1024x768).

from diffusers import DiffusionPipeline
import torch

pipe = DiffusionPipeline.from_pretrained(
    "stabilityai/stable-diffusion-xl-base-1.0",
    torch_dtype=torch.float16,
    use_safetensors=True,
    variant="fp16"
)
pipe.to("cuda")

prompt = "An astronaut riding a green horse"
image = pipe(
    prompt=prompt,
    height=768,
    width=1024,
    num_inference_steps=50
).images[0]
image.save("generated_image.png")

black-forest-labs/FLUX.1-dev

Installation Instructions

Access requires agreeing to the FluxDev License on Hugging Face. Install or upgrade Diffusers with:

pip install -U diffusers

Hugging Face login may be needed for access.

Example Code

The following Python code snippet generates an image with a custom aspect ratio (e.g., 1024x768).

import torch
from diffusers import FluxPipeline

pipe = FluxPipeline.from_pretrained("black-forest-labs/FLUX.1-dev", torch_dtype=torch.bfloat16)
pipe.enable_model_cpu_offload()

prompt = "A cat holding a sign that says hello world"
image = pipe(
    prompt,
    height=768,
    width=1024,
    guidance_scale=3.5,
    num_inference_steps=50,
    max_sequence_length=512,
    generator=torch.Generator("cpu").manual_seed(0)
).images[0]
image.save("flux-dev.png")

dreamlike-art/dreamlike-photoreal-2.0

Installation Instructions

Install the required packages for use with the Diffusers library:

pip install diffusers torch

No authentication is necessary.

Example Code

The following Python code snippet generates an image with a custom aspect ratio (e.g., 896x640).

from diffusers import StableDiffusionPipeline
import torch

model_id = "dreamlike-art/dreamlike-photoreal-2.0"
pipe = StableDiffusionPipeline.from_pretrained(model_id, torch_dtype=torch.float16)
pipe = pipe.to("cuda")

prompt = "photo, a church in the middle of a field of crops, bright cinematic lighting, gopro, fisheye lens"
image = pipe(prompt, height=640, width=896).images[0]
image.save("./result.jpg")

dreamlike-art/dreamlike-diffusion-1.0

Installation Instructions

Install the essential packages for the Diffusers library:

pip install diffusers torch

No authentication is required.

Example Code

The following Python code snippet generates an image with a custom aspect ratio (e.g., 768x512).

from diffusers import StableDiffusionPipeline
import torch

model_id = "dreamlike-art/dreamlike-diffusion-1.0"
pipe = StableDiffusionPipeline.from_pretrained(model_id, torch_dtype=torch.float16)
pipe = pipe.to("cuda")

prompt = "dreamlikeart, a grungy woman with rainbow hair, travelling between dimensions, dynamic pose, happy, soft eyes and narrow chin, extreme bokeh, dainty figure, long hair straight down, torn kawaii shirt and baggy jeans, In style of by Jordan Grimmer and greg rutkowski, crisp lines and color, complex background, particles, lines, wind, concept art, sharp focus, vivid colors"
image = pipe(prompt, height=512, width=768).images[0]
image.save("./result.jpg")

stabilityai/deepfloyd-if

Installation Instructions

Accept the DeepFloyd License on Hugging Face and install:

pip install huggingface_hub --upgrade
pip install diffusers accelerate transformers safetensors sentencepiece

Use huggingface_hub.login() for authentication. Requires a GPU with at least 14 GB VRAM.

Example Code

The following Python code snippet generates an image with a custom aspect ratio (e.g., 96x64 in stage 1 for final portrait ratio).

from diffusers import DiffusionPipeline
from diffusers.utils import pt_to_pil
import torch

stage_1 = DiffusionPipeline.from_pretrained("DeepFloyd/IF-I-XL-v1.0", variant="fp16", torch_dtype=torch.float16)
stage_1.enable_model_cpu_offload()

stage_2 = DiffusionPipeline.from_pretrained("DeepFloyd/IF-II-L-v1.0", text_encoder=None, variant="fp16", torch_dtype=torch.float16)
stage_2.enable_model_cpu_offload()

safety_modules = {"feature_extractor": stage_1.feature_extractor, "safety_checker": stage_1.safety_checker, "watermarker": stage_1.watermarker}
stage_3 = DiffusionPipeline.from_pretrained("stabilityai/stable-diffusion-x4-upscaler", **safety_modules, torch_dtype=torch.float16)
stage_3.enable_model_cpu_offload()

prompt = 'a photo of a kangaroo wearing an orange hoodie and blue sunglasses standing in front of the eiffel tower holding a sign that says "very deep learning"'
generator = torch.manual_seed(0)

prompt_embeds, negative_embeds = stage_1.encode_prompt(prompt)

image = stage_1(prompt_embeds=prompt_embeds, negative_prompt_embeds=negative_embeds, generator=generator, height=64, width=96, output_type="pt").images

image = stage_2(image=image, prompt_embeds=prompt_embeds, negative_prompt_embeds=negative_embeds, generator=generator, output_type="pt").images

image = stage_3(prompt=prompt, image=image, generator=generator, noise_level=100).images

image[0].save("./custom_aspect_if.png")

ttj/flex-diffusion-2-1

Installation Instructions

Install the Diffusers library and related dependencies:

pip install diffusers huggingface_hub

Hugging Face login may be required via huggingface-cli login.

Example Code

The following Python code snippet generates an image with a custom aspect ratio (e.g., 576x1024).

import torch
from diffusers import StableDiffusionPipeline, DPMSolverMultistepScheduler, UNet2DConditionModel

def use_DPM_solver(pipe):
    pipe.scheduler = DPMSolverMultistepScheduler.from_config(pipe.scheduler.config)
    return pipe

pipe = StableDiffusionPipeline.from_pretrained(
    "stabilityai/stable-diffusion-2-1",
    unet=UNet2DConditionModel.from_pretrained("ttj/flex-diffusion-2-1", subfolder="2-1/unet", torch_dtype=torch.float16),
    torch_dtype=torch.float16,
)
pipe = use_DPM_solver(pipe).to("cuda")

prompt = "a professional photograph of an astronaut riding a horse"
image = pipe(prompt, height=1024, width=576, num_inference_steps=20).images[0]
image.save("astronaut_rides_horse.png")

recraft-ai/recraft-v3

Installation Instructions

For the Recraft v3 model with the Diffusers library, install:

pip install diffusers transformers

No authentication is specified; ensure Hugging Face access.

Example Code

The following Python code snippet generates an image with a custom aspect ratio (e.g., 1024x768).

from diffusers import DiffusionPipeline
import torch

pipe = DiffusionPipeline.from_pretrained("recraft-ai/recraft-v3", torch_dtype=torch.float16)
pipe = pipe.to("cuda")

prompt = "A scenic view"
image = pipe(prompt, height=768, width=1024).images[0]
image.save("generated_image.png")

black-forest-labs/FLUX.1.1-pro

Installation Instructions

Access requires agreeing to conditions on Hugging Face. Install or upgrade Diffusers:

pip install -U diffusers

Hugging Face login is necessary.

Example Code

The following Python code snippet generates an image with a custom aspect ratio (e.g., 1024x768). Note: This uses the FLUX.1-schnell variant as a proxy.

import torch
from diffusers import FluxPipeline

pipe = FluxPipeline.from_pretrained("black-forest-labs/FLUX.1-schnell", torch_dtype=torch.bfloat16)
pipe.enable_model_cpu_offload()

prompt = "A cat holding a sign that says hello world"
image = pipe(
    prompt,
    guidance_scale=0.0,
    num_inference_steps=4,
    max_sequence_length=256,
    height=768,
    width=1024,
    generator=torch.Generator("cpu").manual_seed(0)
).images[0]
image.save("flux-schnell.png")

Meme Conversion Tools

MemePy

Installation Instructions

Install the MemePy library via PyPI:

pip install MemePy

Python 3.6+ is required.

Example Code

The following Python code snippet demonstrates creating a meme by adding text to an image template.

from MemePy import MemeGenerator

generator = MemeGenerator()
meme = generator.generate_meme(template="drake", top_text="Top Text", bottom_text="Bottom Text")
meme.save("output_meme.png")

minimaxir/imgmaker

Installation Instructions

Install from GitHub via:

pip3 install imgmaker

Python 3.6+ is supported.

Example Code

The following Python code snippet uses the built-in meme template to add text to an image.

from imgmaker import imgmaker

i = imgmaker()
i.generate(
    "meme",
    {
        "top_text": "Top Text",
        "bottom_text": "Bottom Text",
        "image_url": "https://example.com/your-image.jpg"
    }
)
i.close()

ImageMagick

Installation Instructions

On Ubuntu/Linux: sudo apt install imagemagick
On macOS: brew install imagemagick
On Windows: Download and install from https://imagemagick.org/script/download.php.

Example Code

The following Bash script adds text overlays to an image for a meme effect.

#!/bin/bash

input="input.jpg"
top_text="TOP TEXT"
bottom_text="BOTTOM TEXT"
output="output.png"

magick "$input" \
  -font Bookman-DemiItalic -pointsize 48 -fill white -stroke black -strokewidth 2 \
  -annotate +0+50 "$top_text" \
  -annotate +0-50 "$bottom_text" \
  "$output"

Imgflip API Script

Installation Instructions

No installation required; uses curl (available on most systems). Obtain Imgflip API credentials by signing up at https://imgflip.com.

Example Code

The following Bash script generates a meme using the Imgflip API.

#!/bin/bash

template_id="61579"  # Example: One Does Not Simply
top_text="Top Text"
bottom_text="Bottom Text"
username="your_username"
password="your_password"

curl -s "https://api.imgflip.com/caption_image?template_id=$template_id&username=$username&password=$password&text0=$top_text&text1=$bottom_text"

Taipy GUI Meme Generator

Installation Instructions

Requires Python 3.8+. Install Taipy with:

pip install taipy

Example Code

The following Python code snippet automates meme generation using the Imgflip API.

import requests
import urllib

username = "your_username"
password = "your_password"
userAgent = "your_userAgent"

data = requests.get('https://api.imgflip.com/get_memes').json()['data']['memes']
images = [{'name': image['name'], 'url': image['url'], 'id': image['id']} for image in data]

template_index = 1
top_text = "Top Text Example"
bottom_text = "Bottom Text Example"

def generate_meme(template_index, top_text, bottom_text):
    top_text = top_text.strip()
    bottom_text = bottom_text.strip()
    if not top_text or not bottom_text:
        return None
    URL = 'https://api.imgflip.com/caption_image'
    params = {
        'username': username,
        'password': password,
        'template_id': images[int(template_index) - 1]['id'],
        'text0': top_text,
        'text1': bottom_text
    }
    response = requests.request('POST', URL, params=params).json()
    if 'data' in response:
        meme_url = response['data']['url']
        opener = urllib.request.URLopener()
        opener.addheader('User-Agent', userAgent)
        file_path = images[int(template_index) - 1]['name'] + '.jpg'
        opener.retrieve(meme_url, file_path)
        return meme_url
    return None

meme_url = generate_meme(template_index, top_text, bottom_text)

AI-Memer System

Installation Instructions

No explicit commands provided; use the Google Colab notebook at https://colab.research.google.com/github/robgon-art/ai-memer/blob/main/AI_Memer.ipynb for setup. Requires libraries like openai and transformers.

Example Code

The following Python code snippet generates a meme caption using GPT-Neo.

from transformers import pipeline, AutoTokenizer

prompt_neo = """Create a funny caption for a meme.

Theme: disaster girl Image description: A picture of a girl looking at us as her house burns down Caption: There was a spider. It’s gone now.

Theme: grumpy cat
 Image description: A face of a cat who looks unhappy Caption: I don’t like Mondays.

Theme: apple pie. Image description: Simple and easy apple pie served with vanilla ice cream, on a gingham tablecloth in Lysekil, Sweden.
 Caption:"""

gpt_neo_tokenizer = AutoTokenizer.from_pretrained("EleutherAI/gpt-neo-2.7B")
generator = pipeline('text-generation',
                     device=0,
                     model='EleutherAI/gpt-neo-2.7B',
                     tokenizer=gpt_neo_tokenizer)

results = generator(prompt_neo,
                    do_sample=True,
                    min_length=50,
                    max_length=150,
                    temperature=0.7,
                    top_p=1.0,
                    pad_token_id=gpt_neo_tokenizer.eos_token_id)

caption_neo = results[0]['generated_text'].split('Caption:')[-1].strip().upper()
print("Generated Caption (GPT-Neo):", caption_neo)

HuggingFaceM4/AI_Meme_Generator

Installation Instructions

Install the Hugging Face Hub library for API access:

pip install huggingface_hub

Use the Space's API endpoint for scripting.

Example Code

The following Python code snippet calls the API to generate a meme (adapt based on Space documentation).

from huggingface_hub import InferenceClient

client = InferenceClient(model="HuggingFaceM4/AI_Meme_Generator")
prompt = "Generate a meme about AI"
response = client.text_generation(prompt)
print(response)

bickett/meme-llama

Installation Instructions

Install the Transformers library:

pip install transformers

Example Code

The following Python code snippet generates a meme caption. Integrate with Pillow for image overlay.

from transformers import AutoTokenizer, AutoModelWithLMHead

tokenizer = AutoTokenizer.from_pretrained("bickett/meme-llama")
model = AutoModelWithLMHead.from_pretrained("bickett/meme-llama")

input_text = "When you try to code without coffee"
input_ids = tokenizer.encode(input_text, return_tensors="pt")
output = model.generate(input_ids)

print(tokenizer.decode(output[0], skip_special_tokens=True))
Linux Rocks Every Day