def surpriseMemes (x): if x == 0: make_meme("Stays up till 4 every night" , "Body is tired", "opencv_frame_0.png") elif x == 1: make_meme("Codes a Project" , "Code Compiles for the First time", "opencv_frame_0.png") elif x == 2: make_meme("Project 2 is Due Next Week" , "Project 3 is Assigned", "opencv_frame_0.png") elif x == 3: make_meme("Scores 100% on Coding Interview" , "Rejected by Company", "opencv_frame_0.png") elif x == 4: make_meme("Run Code for the First Time" , "No Compile Time Errors", "opencv_frame_0.png")
def sadMemes (x): if x == 0: make_meme("Tries to Remove Swap File" , "Removes Actual File", "opencv_frame_0.png") elif x == 1: make_meme("Puts dignity at stake and runs for the LX" , "Bus driver doesn't stop", "opencv_frame_0.png") elif x == 2: make_meme("Tries to Have a Social Life" , "Welcome to Data Structures","opencv_frame_0.png") elif x == 3: make_meme("Spend 24 Hours Coding" , "Code Doesnt Compile", "opencv_frame_0.png") elif x == 4: make_meme("Hackathon Group Promises to Stay Awake" , "Everyone Goes to Sleep", "opencv_frame_0.png")
async def memegen_parse(meme, text, message): channel = message.channel lines = text.split(',') for line in range(len(lines)): lines[line] = lines[line].upper().strip() if len(lines) < 2: lines.append('') print(f"Generating {meme} meme: {lines[0]}, {lines[1]}") make_meme(lines[0], lines[1], meme) await channel.send( file=discord.File(os.path.join(MEMEGEN_OUTPUT, f"{meme}.jpg"))) await message.delete()
def joyMemes (x): if x == 0: make_meme("When you open WebReg" , "and a CS class is open", "opencv_frame_0.png") elif x == 1: make_meme("When you are waiting for the bus" , "and you end up right in front of the door", "opencv_frame_0.png") elif x == 2: make_meme("CS Know-it-all Takes Exam" , "Does Worse Than You", "opencv_frame_0.png") elif x == 3: make_meme("Takes Interview with a Company while at Rutgers" , "Interview is in Java", "opencv_frame_0.png") elif x == 4: make_meme("Knows Nothing about APIs" , "Gets an API to work for Hackathon", "opencv_frame_0.png")
def angerMemes (x): if x == 0: make_meme("Python is Admirable Skill for CS" , "Lets Learn C Programming", "opencv_frame_0.png") elif x == 1: make_meme("Deadline is 12:00" , "Submitted on 12:01") elif x == 2: make_meme("Eats unhealthy as a college student" , "Attends a Hackathon", "opencv_frame_0.png") elif x == 3: make_meme("Tries to Meet Significant Other" , "Realizes That You Are a CS Major", "opencv_frame_0.png") elif x == 4: make_meme("Want to Take a Quick Nap" , "Oversleeps by 10 Hours", "opencv_frame_0.png")
def makememe(outputname="temp.png"): filename = "" while filename == "" or filename == "./templates/.DS_Store": filename = "./templates/" + random.choice(os.listdir("./templates")) content = getContent() contentLength = len(content) breakIndex = 0 for i in range(contentLength / 2, contentLength): if content[i] == " ": breakIndex = i break memegenerator.make_meme(content[:breakIndex], content[breakIndex + 1:], filename, outputname) '''
def sadMemes(x): if x == 0: make_meme("Tries to Remove Swap File", "Removes Actual File", "opencv_frame_0.png") elif x == 1: make_meme("Too Busy Doing Database Project", "Forgets Valentines Day", "opencv_frame_0.png") elif x == 2: make_meme("Tries to Have a Social Life", "Welcome to Data Structures", "opencv_frame_0.png") elif x == 3: make_meme("Spend 24 Hours Coding", "Code Doesnt Compile", "opencv_frame_0.png") elif x == 4: make_meme("Hackathon Group Promises to Stay Awake", "Everyone Goes to Sleep", "opencv_frame_0.png")
def patsan_message(message): if matches := re.findall(REGEX, message.text.lower()): word = matches[-1].capitalize() image = get_image_for_meme(word) upper, lower = generate_message(first=[word], split=True) img = make_meme(upper, lower, image) with open(img, 'rb') as file: bot.send_photo(message.chat.id, file)
def joyMemes(x): if x == 0: make_meme("Uses Python For the First Time", "Successful ... Almost", "opencv_frame_0.png") elif x == 1: make_meme("Cant Figure Out Some Code", "Finds a Library", "opencv_frame_0.png") elif x == 2: make_meme("CS Know-it-all Takes Exam", "Does Worse Than You", "opencv_frame_0.png") elif x == 3: make_meme("Takes Interview with a Company while at Rutgers", "Interview is in Java", "opencv_frame_0.png") elif x == 4: make_meme("Knows Nothing about APIs", "Gets an API to work for Hackathon", "opencv_frame_0.png")
def meme(): photos_directory = "backend/farnam/" captions_file = "backend/captions.txt" photos = listdir(photos_directory) captions = open(captions_file, "r").read().split('\n') photo = photos_directory + random.choice(photos) caption = random.choice(captions) cap_split = str.split(caption) top_caption = " ".join(cap_split[0:(int)(len(cap_split) / 2)]) bottom_caption = " ".join(cap_split[(int)(len(cap_split) / 2):]) make_meme(top_caption, bottom_caption, photo) r = send_file("../temp.png") r.headers["Cache-Control"] = "no-cache, no-store, must-revalidate" r.headers["Pragma"] = "no-cache" r.headers["Expires"] = "0" r.headers['Cache-Control'] = 'public, max-age=0' return r
def surpriseMemes(x): if x == 0: make_meme("Uses Python for the First time", "Almost Successful", "opencv_frame_0.png") elif x == 1: make_meme("Codes a Project", "Code Compiles for the First time", "opencv_frame_0.png") elif x == 2: make_meme("Project 2 is Due Next Week", "Project 3 is Assigned", "opencv_frame_0.png") elif x == 3: make_meme("Scores 100% on Coding Interview", "Rejected by Company", "opencv_frame_0.png") elif x == 4: make_meme("Run Code for the First Time After Saving", "No Compile Time Errors", "opencv_frame_0.png") #img = Image.open('opencv_frame_0.png') #img.show() #mg = Image.open('temp.png') #img.show() v
def create_meme(name, top_text, bottom_text): source_images = list_source_images() source_image_names = [i.get("title") for i in source_images] # Find correct download url source_image = source_images[source_image_names.index(name)] image_url = source_image["thumb_url"] # Make meme to local file buffer = make_meme(top_text, bottom_text, image_url) # Upload meme to Cloudinary upload = cloudinary.uploader.upload(buffer) buffer.close() # Respond with downloadable url response = { "response_type": "in_channel", "attachments": [{ "image_url": upload['secure_url'], "text": "" }] } return json.dumps(response)
cam.release() cv2.destroyAllWindows() main("opencv_frame_0.png", "face_image.png", 4) str2 = detect_face2("face_image.png") y = random.randint(0, 4) print(y) if str2 == "Sadness": #print("inhere") sadMemes(y) elif str2 == "Joy": joyMemes(y) elif str2 == "Anger": angerMemes(y) elif str2 == "Surprised": surpriseMemes(y) elif str2 == "Unknown": make_meme("Sorry, Unable to Recognize Face!", "", "opencv_frame_0.png") #make all the files go to opencv_frame_0.png, or we can change in meme generator, to open whatever. img = Image.open('temp.png') img.show() #str = "Joy" #make_meme("WASSUP", "HI", "opencv_frame_0.png") #sadMemes(1, "face_image.png")
return new_list N = 2000 topics = wikipedia.random(pages=N) topics = remove_nonascii(topics) N = len(topics) meme_list = [] for i in range(0, N): slogan = get_slogan(topics[i]) if slogan != '0': meme = slogan + " (from " + topics[i] + ')' print(meme) meme_list.append(meme) meme_list = remove_nonascii(meme_list) from img_search import get_image from memegenerator import make_meme image_topics = wikipedia.random(pages=2 * N) image_topics = remove_nonascii(image_topics) for i in range(len(meme_list)): img_topic = image_topics[i] try: get_image(img_topic) make_meme("Keep calm and ", meme_list[i], img_topic + ".jpg") except: k = 1