DEV Community

John Mark Bulabos
John Mark Bulabos

Posted on

Top 5 AI Python Projects That Will Make Your Friends Think You’re a Genius

Let’s face it - AI is taking over. In fact, it’s getting so smart, it might even replace your friends if they aren’t careful. But hey, let’s use this AI-pocalypse to our advantage and become the envy of the town with Python projects that will make your friends think you’re the real Tony Stark!

🤓🤖💻

1. The Smart Meme Generator

Ah, the art of memes. Truly the poetry of our generation. But manually making memes is so 2010. Let's automate it with our AI buddy.

Code Snippet:

from PIL import Image, ImageDraw, ImageFont
import requests
from transformers import GPT2Tokenizer, GPT2LMHeadModel

# Meme image URL
meme_url = 'https://example.com/path-to-meme.jpg'
image = Image.open(requests.get(meme_url, stream=True).raw)

# GPT2 meme text generation
tokenizer = GPT2Tokenizer.from_pretrained('gpt2')
model = GPT2LMHeadModel.from_pretrained('gpt2')
input_text = "Meme text: "
output = model.generate(tokenizer.encode(input_text, return_tensors='pt'), max_length=30)
meme_text = tokenizer.decode(output[0], skip_special_tokens=True)

# Add text to image
draw = ImageDraw.Draw(image)
font = ImageFont.load_default()
draw.text((10, 10), meme_text, font=font, fill='white')
image.show()
Enter fullscreen mode Exit fullscreen mode

Disclaimer:

This code is just for fun. Please don’t replace human creativity with a robot. Meme responsibly.

2. Recipe Recommender - Your AI Chef!

Ever stared blankly into your fridge? AI to the rescue! Your new virtual chef will cook up a storm, suggesting recipes based on the ingredients you have.

Code Snippet:

import random

recipes = {
    'Egg & Cheese': ['egg', 'cheese'],
    'Peanut Butter & Jelly Sandwich': ['bread', 'peanut butter', 'jelly']
}

ingredients = input("Enter your ingredients, separated by commas: ").split(',')

recommendations = [recipe for recipe, required_ingredients in recipes.items() if all(ingredient in ingredients for ingredient in required_ingredients)]

print("AI Chef recommends: " + random.choice(recommendations))
Enter fullscreen mode Exit fullscreen mode

Disclaimer:

Results may vary. AI chef not responsible for any culinary disasters.

3. Your Own Jarvis!

Imagine yelling “JARVIS, play Eye of the Tiger” every time you need to code. Well, pinch yourself, because you’re not dreaming!

Code Snippet:

import speech_recognition as sr
import pyttsx3

def process_command(command):
    if "play Eye of the Tiger" in command:
        # Add code to play music
        pass
    # Add more commands here

recognizer = sr.Recognizer()

engine = pyttsx3.init()
engine.say("I'm listening, master!")
engine.runAndWait()

with sr.Microphone() as source:
    audio = recognizer.listen(source)
    command = recognizer.recognize_google(audio).lower()
    process_command(command)
Enter fullscreen mode Exit fullscreen mode

Disclaimer:

Remember to play music at a responsible volume. Also, AI cannot iron your suit or make you a billionaire. Yet.

4. A Tweet Predictor 🐦

Want to predict what Elon Musk will tweet next? Let’s roll! With some AI magic, you’ll be one step ahead of the Twitter curve.

Code Snippet:

from transformers import pipeline

tweet_predictor = pipeline("text-generation", model="gpt-2")

input_tweet = "Elon Musk just announced "
predicted_tweet = tweet_predictor(input_tweet, max_length=50)

print(predicted_tweet[0]['generated_text'])
Enter fullscreen mode Exit fullscreen mode

Disclaimer:

No AIs were harmed in predicting tweets. The results are fictional and for entertainment only. Don’t quote us on Wall Street!

5. Rock-Paper-Scissors with AI

Outsmart your friends by building a Rock-Paper-Scissors game, but with an AI opponent that learns from every move. Be warned - it learns faster than a caffeinated college student.

Code Snippet:

import random
from sklearn.naive_bayes import MultinomialNB
import numpy as np

# Rock=0, Paper=1, Scissors=2
data = np.random.randint(0, 3, (10, 1))
target = np.random.randint(0, 3, 10)

clf = MultinomialNB()
clf.fit(data, target)

# Play the game!
human_input = input("Enter rock, paper, or scissors: ")
mapping = {'rock': 0, 'paper': 1, 'scissors': 2}
ai_input = clf.predict([[mapping[human_input]]])[0]

outcomes = ["It's a tie!", "You win!", "AI wins!"]
print(outcomes[(ai_input - mapping[human_input]) % 3])
Enter fullscreen mode Exit fullscreen mode

Disclaimer:

This AI might not be an RPS grandmaster. If you find yourself losing, remember it’s just a game and don’t throw your computer out the window.


So there you have it, folks! Top 5 AI Python projects that are more dazzling than a disco ball at a science fair. With these projects, you’re not just climbing the coolness ladder - you’re building your own rocket ship to Coolville. 🚀

Oh, and a word of advice: always treat AI with respect. They might just be the ones picking your retirement home. 😉

If you had a blast with these projects and your friends are already lining up for your autograph, don't forget to dive deeper into the AI wonderland. But, wait! Before you go back to being the Einstein of our era, don't forget to check out the incredible PAIton and Crossovers on YouTube for more AI escapades. They are like the peanut butter to your AI jelly.

Top comments (0)