I am writing a telegram bot, one of the functions of which is face recognition. The user sends a photo to the chat. Is it possible to send it as a file to the function parameter without saving the photo to the database?
I have a class "PhotoAnalyser" and a function in it "analyse_photo":
class PhotoAnalyser:
@staticmethod
def analyse_photo(file):
temp = []
for prediction in model.predict(file, confidence=30, overlap=30).json()['predictions']:
temp.append(prediction['class'])
model.predict(file, confidence=30, overlap=30).save(f'{file}_prediction.jpg')
return temp
I tried to send a photo as message.photo
PhotoAnalyser.analyse_photo(message.photo)
;
by ID
PhotoAnalyser.analyse_photo(message.photo[0].file_id)
.
But an error popped up that the value should be either str or nparray. Altered the type under nparray, writes that it cannot read the value.
I tried to remove the json() method in the loop in the function "analyse_photo", but that didn't help either.
In this regard, I decided to find out if there is a way to send a photo immediately as a file