-
-
Notifications
You must be signed in to change notification settings - Fork 191
Contrib/logogenerator #378
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
NOUN_PROJECT_KEY= c87a8c5fb6354664af47395db447cc72 | ||
NOUN_PROJECT_SECRET= 3809573e72fc4125b4c33782b0c74229 |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
# Setup | ||
|
||
``` | ||
git clone https://github.com/MLDSAI/OpenAdapt.git | ||
cd OpenAdapt/contrib/wordlyworks | ||
python3 -m venv .venv | ||
source .venv/bin/activate | ||
pip install -r requirements.txt | ||
cp .env.example .env # open .env and fill in the values | ||
``` | ||
|
||
# Run | ||
``` | ||
python main.py | ||
``` |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
""" | ||
Use named entity recognition to extract entities from text description (e.g. Spacy) | ||
Download SVGs from https://thenounproject.com/ | ||
Ask large language model to arrange | ||
Generate combined SVG | ||
Run through e.g. Stable Diffusion and/or ask large language model to generate animation code | ||
""" | ||
|
||
from pprint import pformat | ||
from requests_oauthlib import OAuth1 | ||
import os | ||
import requests | ||
from contrib.wordlyworks import ner.ner | ||
|
||
from dotenv import load_dotenv | ||
from loguru import logger | ||
import ner | ||
#from TheNounProjectAPI import API | ||
|
||
|
||
load_dotenv() | ||
|
||
|
||
def main(): | ||
key = os.environ["NOUN_PROJECT_KEY"] | ||
secret = os.environ["NOUN_PROJECT_SECRET"] | ||
logger.info(f"{key=} {secret=}") | ||
|
||
|
||
auth = OAuth1(key, secret) | ||
endpoint = "https://api.thenounproject.com/v2/icon/1" | ||
|
||
response = requests.get(endpoint, auth=auth) | ||
logger.info(f"response=\n{pformat(response.json())}") | ||
|
||
if 0: | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Remove this There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @abrichr just a question. Why remove all this code? The Additionally, There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Nevermind I think I know why we need to remove all of this because the blacklist function will send a get request on behalf of the app. |
||
api = API(key=key, secret=secret) | ||
icons = api.get_icons_by_term("goat", public_domain_only=True, limit=2) | ||
for icon in icons: | ||
print("Icon's term:", icon.term) | ||
print("This icon's tags:", ", ".join(tag.slug for tag in icon.tags)) | ||
print("Uploader's username:", icon.uploader.username) | ||
|
||
|
||
if __name__ == "__main__": | ||
main() |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
import spacy | ||
|
||
|
||
def ner(): | ||
nlp = spacy.load("en_core_web_sm") | ||
|
||
text_description = ''' | ||
Apple Inc. is planning to open a new factory in Austin, Texas. | ||
The plan will reportedly cost $1 billion and create jobs for 5,000 people. | ||
Apple's CEO, Tim Cook, will oversee the new project. | ||
''' | ||
|
||
document_object = nlp(text_description) | ||
|
||
for entity in document_object.ents: | ||
print(f"{entity.text}, ({entity.label_})") | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. No need to print, just return the relevant entities. Also, please move this function to |
||
|
||
|
||
if __name__ == "__main__": | ||
ner() | ||
|
||
|
||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
loguru==0.7.0 | ||
python-dotenv==1.0.0 | ||
#TheNounProjectAPI==1.0.5 | ||
|
||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Consult the noun project API to determine which URL to use in order to search, and search for each of the entities returned by
get_entities
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sounds good 👍 based on my current research I think we should use their
blacklist
endpoint. It allows for more control over their icons relatively compared to their other APIs.The blacklist API is pretty neat if there are irrelevant or inappropriate terms. They will automatically be excluded compared to their
icons
endpoint.I'll have some stuff for us to chat about on Friday!