Jan-30-2021, 05:32 PM
(This post was last modified: Jan-30-2021, 05:32 PM by ivo_georgiev.)
Hello everybody,
please do not laugh at me, because I have absolutely 0 knowledge of programming. I did this project, where you train a machine learning to responds to what you say to it.
Here is the python code I got :
Now I wanted to take this one step further and make an executable file out of it (with pyinstaller, which I did) and send it to my friends as a joke. The idea is that they write something nice, they get the nice response and a picture of me smiling is opened from an url. If they say mean things, then they get the mean response and an angry picture of me opens.
This is what I have tried to far:
I assume this is a very basic thing to code, but please help me do it
please do not laugh at me, because I have absolutely 0 knowledge of programming. I did this project, where you train a machine learning to responds to what you say to it.
Here is the python code I got :
from PIL import Image import requests def classify(text): key = "#my credits activation key" url = "https://machinelearningforkids.co.uk/api/scratch/"+ key + "/classify" response = requests.get(url, params={ "data" : text }) if response.ok: responseData = response.json() topMatch = responseData[0] return topMatch else: response.raise_for_status() input = input("What do you want to tell me? > ") recognized = classify(input) label = recognized["class_name"] if label == "kind_things": print ("Mmm, thanks") img = Image.open("happy.png") img.show() else: print ("Well fuck you too!") img = Image.open("sad.png") img.show()This way it works, so I assume I have everything properly installed (pip, pillow etc)
Now I wanted to take this one step further and make an executable file out of it (with pyinstaller, which I did) and send it to my friends as a joke. The idea is that they write something nice, they get the nice response and a picture of me smiling is opened from an url. If they say mean things, then they get the mean response and an angry picture of me opens.
This is what I have tried to far:
if label == "kind_things": print ("Mmm, thanks") url = "#url of the picture" response = requests.get(url) img = Image.open(response.raw) img.show() else: print ("Well fuck you too!") url = "#url of the other picture" response = requests.get(url) img = Image.open(response.raw) img.show()It doesn't work. I read about stuff like "urllib" or "bytesIO" or "StringIO" but it only made a huge chaos in my head and I have been trying to get this to work for the last 5 hours



I assume this is a very basic thing to code, but please help me do it
