This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from clarifai.rest import ClarifaiApp | |
app = ClarifaiApp() | |
def get_concept_tags(image_url): | |
response_data = app.tag_urls([image_url]) | |
tags = [] | |
for concept in response_data['outputs'][0]['data']['concepts']: | |
tags.append(concept['name']) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from flask import Flask, request | |
from twilio.twiml.messaging_response import MessagingResponse | |
from clarifai_tagger import get_concept_tags | |
app = Flask(__name__) | |
#this is a list of concepts we will look for among all possible Clarifai concepts | |
spooky_concepts = ['scary','eerie','dark','monochrome','spider','spiderweb', | |
'arachnid','phobia','fog','mystery','shadow','abandoned', |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from IPython.display import Image | |
from IPython.core.display import HTML | |
Image(url="") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def prepare_for_fasttext(tweets_df): | |
with open('tweets.txt', 'w') as file: | |
for i, row in tweets_df.iterrows(): | |
if row['class'] == 0: | |
label = ' __label__ hate_speech' | |
if row['class'] == 1: | |
label = ' __label__ offensive_language' | |
else: | |
label = ' __label__ neither' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def memo(f): | |
"Memoize function f, whose args must all be hashable." | |
cache = {} | |
def fmemo(*args): | |
if args not in cache: | |
cache[args] = f(*args) | |
return cache[args] | |
fmemo.cache = cache | |
return fmemo |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.