-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathutils.py
More file actions
31 lines (25 loc) · 1.1 KB
/
utils.py
File metadata and controls
31 lines (25 loc) · 1.1 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
from clarifai.rest import ClarifaiApp
from telegram import ReplyKeyboardMarkup, KeyboardButton
import settings
def get_keyboard():
contact_button = KeyboardButton('Прислать контакты', request_contact=True)
location_button = KeyboardButton('Прислать координаты', request_location=True)
my_keyboard = ReplyKeyboardMarkup([
['Прислать котика', 'Сменить аватарку'],
[contact_button, location_button],
['Заполнить анкету']
], resize_keyboard=True)
return my_keyboard
def is_cat(file_name):
image_has_cat = False
app = ClarifaiApp(api_key=settings.CLARIFAI_API_KEY)
model = app.public_models.general_model
response = model.predict_by_filename(file_name, max_concepts=5)
if response['status']['code'] == 10000:
for concept in response['outputs'][0]['data']['concepts']:
if concept['name'] == 'cat':
image_has_cat = True
return image_has_cat
if __name__ == "__main__":
print(is_cat('images/cat1.jpg'))
print(is_cat('images/not_cat1.jpg'))