{ "cells": [ { "cell_type": "code", "execution_count": 14, "metadata": {}, "outputs": [], "source": [ "exampleData = {'images': ['https://assets-global.website-files.com/64f6fcb22fc6650621823722/6604669ba540f869e121c7b0_PNG-500_h-single_full.png', 'https://assets-global.website-files.com/64f6fcb22fc6650621823722/64f8792a64b8b84068d0968c_Codehouse-removebg-preview.png', 'https://assets-global.website-files.com/64f6fcb22fc6650621823722/6604669ba540f869e121c7b0_PNG-500_h-single_full.png', 'https://assets-global.website-files.com/64f6fcb22fc6650621823722/64f8792a64b8b84068d0968c_Codehouse-removebg-preview.png', 'https://assets-global.website-files.com/64f6fcb22fc6650621823722/6604669ba540f869e121c7b0_PNG-500_h-single_full.png', 'https://assets-global.website-files.com/64f6fcb22fc6650621823722/64f8792a64b8b84068d0968c_Codehouse-removebg-preview.png', 'https://assets-global.website-files.com/64f6fcb22fc6650621823722/6604669ba540f869e121c7b0_PNG-500_h-single_full.png', 'https://assets-global.website-files.com/64f6fcb22fc6650621823722/64f8792a64b8b84068d0968c_Codehouse-removebg-preview.png', 'https://assets-global.website-files.com/64f6fcb22fc6650621823722/6604669ba540f869e121c7b0_PNG-500_h-single_full.png', 'https://assets-global.website-files.com/64f6fcb22fc6650621823722/64f8792a64b8b84068d0968c_Codehouse-removebg-preview.png', 'https://assets-global.website-files.com/64f6fcb22fc6650621823722/6604669ba540f869e121c7b0_PNG-500_h-single_full.png', 'https://assets-global.website-files.com/64f6fcb22fc6650621823722/64f8792a64b8b84068d0968c_Codehouse-removebg-preview.png', \n", "'https://assets-global.website-files.com/64f6fcb22fc6650621823722/6604669ba540f869e121c7b0_PNG-500_h-single_full.png', 'https://assets-global.website-files.com/64f6fcb22fc6650621823722/64f8792a64b8b84068d0968c_Codehouse-removebg-preview.png', 'https://assets-global.website-files.com/64f6fcb22fc6650621823722/6604669ba540f869e121c7b0_PNG-500_h-single_full.png', 'https://assets-global.website-files.com/64f6fcb22fc6650621823722/64f8792a64b8b84068d0968c_Codehouse-removebg-preview.png', 'https://assets-global.website-files.com/64f6fcb22fc6650621823722/651488cfeb9835540251622a_drew_schwartz.jpeg', 'https://assets-global.website-files.com/64f6fcb22fc6650621823722/651488a8a9e33114581e251d_jas_espinosa.jpeg', 'https://assets-global.website-files.com/64f6fcb22fc6650621823722/6514887e5ff4e3a188f0f6e6_estelle-freedman_profilephoto.jpg', 'https://assets-global.website-files.com/65045b272270a1f11782fa52/660460830916d33cb1917ead_RenewScale-hero.jpg', 'https://assets-global.website-files.com/65045b272270a1f11782fa52/65b15e79a3fdcd7102133a2e_PDC-hero.jpg', 'https://assets-global.website-files.com/65045b272270a1f11782fa52/651dec8e708d32af7fbcb815_collegeF-hero.jpg', 'https://assets-global.website-files.com/65045b272270a1f11782fa52/651ded7f0c43865b9b116c3d_piggyback-hero.jpg'], \n", "'text': ['Cusdom Agency', 'We help businesses make', 'Websites', 'Wireframes', 'MVPs', 'Apps', 'Websites', 'We help small businesses, startups, and non-profits make clean, good looking, and maintainable websites, mobile apps, and SAAS products.', 'What We Specialize In', 'Development', 'We are dedicated to delivering exceptional solutions that cater to the needs of our clients. Our expertise spans two key domains: crafting cutting-edge Webflow websites and architecting robust full-stack projects. With a user-centric design philosophy, we take pride in merging functionality and aesthetics to create digital experiences that leave a lasting impact. Discover the difference Cusdom can make for your business today.', 'Design', \"Whether it's crafting visually stunning user interfaces for Webflow websites or designing intuitive user experiences for web or mobile applications, our design team is your creative partner from concept to completion. We pride ourselves on infusing every project with a distinct visual identity that captures your brand's essence. When you choose Cusdom, you choose design that resonates, captivates, and elevates your online presence.\", 'Development', 'Design', 'We are dedicated to delivering exceptional solutions that cater to the needs of our clients. Our expertise spans two key domains: crafting cutting-edge Webflow websites and architecting robust full-stack projects. With a user-centric design philosophy, we take pride in merging functionality and aesthetics to create digital experiences that leave a lasting impact. Discover the difference Cusdom can make for your business today.', \"Whether it's crafting visually stunning user interfaces for Webflow websites or designing intuitive user experiences for web or mobile applications, our design team is your creative partner from concept to completion. We pride ourselves on infusing every project with a distinct visual identity that captures your brand's essence. When you choose Cusdom, you choose design that resonates, captivates, and elevates your online presence.\", '...and more', 'Our Past Clients', '\"What sets them apart is their ability to solve complex problems related to tech and business growth.\"', 'Their approach and expertise have proved vital and timely for our growth. What sets them apart is their ability to solve complex problems related to tech and business growth. While maintaining a sense of urgency, their clear communication and methodical approach to ensuring long-term goals has helped keep our customers happy as we grow.', 'Our Work', 'RenewScale', 'Branding and web design for an up-and-coming cleantech company.', 'RenewScale', 'Branding and web design for an up-and-coming cleantech company.', 'PDC Strategy', 'A rebrand and web redesign project for a consulting firm in the pharmaceutical industry.', 'PDC Strategy', 'A rebrand and web redesign project for a consulting firm in the pharmaceutical industry.', 'College Fans', 'Full-stack MVP for a startup that wanted to create a bidding site where college athletes would auction off signed memorabilia. ', 'College Fans', 'Full-stack MVP for a startup that wanted to create a bidding site where college athletes would auction off signed memorabilia. ', 'Piggyback', 'Custom full-stack web app built with React that helps kids with their reading comprehension.', 'Piggyback', 'Custom full-stack web app built with React that helps kids with their reading comprehension.', '\"GoCusdom delivered a quality product in a fraction of the time and cost.\"', 'GoCusdom delivered a quality product in a fraction of the time and cost. They took into consideration our non-profit budget and offered feasible options that still met our operational needs and ideal aesthetic. We were most impressed with their attention to detail, thoughtful feedback sessions, and rapid response times. All feedback was diligently implemented and we ended up with a website that exceeded our expectations. From start to finish, GoCusdom made the process seamless for us. Highly recommend them!', 'Get In touch', 'Partner with us!', 'Fill out this form or email us at contact@gocusdom.com to get in touch!', '\"Working with Cusdom Agency made designing and implementing a web app user interface more rewarding than I could have imagined.\"', 'Their technical, communication, and interpersonal skills -- including open-mindedness and the ability to work productively with a team, and within deadline and budget projections – exceeded even the glowing recommendation that led me to them.']}\n", "\n", "exampleReq = {\"num_images\":2,\"use_images\":False,\"use_text\":True,\"num_keywords_text\":10,\"num_keywords_image\":10}\n" ] }, { "cell_type": "code", "execution_count": 17, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "https://assets-global.website-files.com/64f6fcb22fc6650621823722/6604669ba540f869e121c7b0_PNG-500_h-single_full.png\n", "{'keywords': [{'keyword': 'illustration', 'score': 0.5398298875207169}, {'keyword': 'vector', 'score': 0.43059240623379835}, {'keyword': 'symbol', 'score': 0.3472509577809335}, {'keyword': 'design', 'score': 0.3433711869390988}, {'keyword': 'icon', 'score': 0.3428570370889158}, {'keyword': 'sign', 'score': 0.27618708281507426}, {'keyword': 'isolated', 'score': 0.24498198256987372}, {'keyword': 'blue', 'score': 0.19170861821953242}, {'keyword': 'medicine', 'score': 0.17357526739180296}, {'keyword': 'education', 'score': 0.15949407887972872}], 'status': 'ok'}\n", "https://assets-global.website-files.com/65045b272270a1f11782fa52/65b15e79a3fdcd7102133a2e_PDC-hero.jpg\n", "{'keywords': [{'keyword': 'data', 'score': 0.5034697541907915}, {'keyword': 'brochure', 'score': 0.49673609601407837}, {'keyword': 'business', 'score': 0.46380304540749107}, {'keyword': 'document', 'score': 0.43736081636048446}, {'keyword': 'illustration', 'score': 0.4266467193303007}, {'keyword': 'plan', 'score': 0.42204836443490595}, {'keyword': 'vector', 'score': 0.3629546656996507}, {'keyword': 'backgrounds', 'score': 0.3496025845836267}, {'keyword': 'design', 'score': 0.31036214066082113}, {'keyword': 'abstract', 'score': 0.28746269723780354}], 'status': 'ok'}\n" ] } ], "source": [ "import requests \n", "from dotenv import load_dotenv\n", "import os\n", "import random\n", "\n", "\n", "load_dotenv()\n", "def request_image_analysis(api_url, api_client, api_key, image_url, num_keyword=10):\n", " params={'url':image_url,'num_keywords':num_keyword}\n", " try:\n", " response = requests.get(api_url, params=params, auth=(api_client, api_key))\n", " response.raise_for_status() \n", " data = response.json() \n", " print(data) \n", " return data\n", " except requests.exceptions.RequestException as e:\n", " return({\"error\":\"Failed Image keywording call\",\"message\":e})\n", "\n", "def analyseImages(images:list,req:dict):\n", " api_url = os.environ.get('AIGENENDPOINT') \n", " api_key = os.environ.get('AIGENKEY')\n", " api_client = os.environ.get('AIGENCLIENT')\n", "\n", " selectedImages = random.sample(images,req[\"num_images\"])\n", " keywords = []\n", " for image in selectedImages:\n", " res= request_image_analysis(api_url,api_client,api_key,image)\n", " if(\"error\" in res):\n", " return res\n", " else:\n", " keywords+= res['keywords']\n", "\n", "analyseImages(exampleData['images'],exampleReq)\n", "\n" ] }, { "cell_type": "code", "execution_count": 12, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "{'keywords': [{'keyword': 'animal', 'score': 0.9718916489849907}, {'keyword': 'cute', 'score': 0.9601239529000117}, {'keyword': 'pets', 'score': 0.949350643787409}, {'keyword': 'kitten', 'score': 0.9039852518100446}, {'keyword': 'domestic cat', 'score': 0.8818465735911328}, {'keyword': 'domestic animals', 'score': 0.773913246291121}, {'keyword': 'young animal', 'score': 0.6324827753197934}, {'keyword': 'mammal', 'score': 0.5434195324260841}, {'keyword': 'feline', 'score': 0.4977278418785077}, {'keyword': 'small', 'score': 0.46956064184549734}], 'status': 'ok'}\n" ] } ], "source": [ "client_id = os.environ.get('AIGENCLIENT')\n", "client_secret = os.environ.get('AIGENKEY')\n", "#print(client_id,client_secret)\n", "params = {'url': 'http://image.everypixel.com/2014.12/67439828186edc79b9be81a4dedea8b03c09a12825b_b.jpg', 'num_keywords': 10}\n", "keywords = requests.get('https://api.everypixel.com/v1/keywords', params=params, auth=(client_id, client_secret)).json()\n", "print(keywords)\n" ] }, { "cell_type": "code", "execution_count": 1, "metadata": {}, "outputs": [], "source": [ "exampleRet = {'keywords_images': {'0': [{'keyword': 'sign', 'score': 0.6898373278547406}, {'keyword': 'symbol', 'score': 0.4472937186719514}, {'keyword': 'design', 'score': 0.2713939913056557}, {'keyword': 'architecture', 'score': 0.2713049676643986}, {'keyword': 'illustration', 'score': 0.26296517362059374}, {'keyword': 'success', 'score': 0.15815140125121907}, {'keyword': 'night', 'score': 0.1436041312950442}, {'keyword': 'icon', 'score': 0.14356085864611598}, {'keyword': 'finance', 'score': 0.13994914050650978}, {'keyword': 'ideas', 'score': 0.13742065469130105}]}, 'keywords_text': ['web', 'design', 'website', 'cusdom', 'business', \n", "'project', 'experience', 'user', 'college', 'startup']}" ] }, { "cell_type": "code", "execution_count": 2, "metadata": {}, "outputs": [], "source": [ "#accepts a list from anypixels in the form: [{'keyword': 'sign', 'score': 0.6898373278547406}...]\n", "def parseImgLis(keywordlist:list):\n", " res = []\n", " for entry in keywordlist:\n", " res.append(entry[\"keyword\"]) \n", " return res\n", "\n", "assert(parseImgLis(exampleRet['keywords_images']['0'])==[\"sign\",\"symbol\",\"design\",\"architecture\",\"illustration\",\"success\",\"night\",\"icon\",\"finance\",\"ideas\"])" ] }, { "cell_type": "code", "execution_count": 13, "metadata": {}, "outputs": [ { "ename": "SyntaxError", "evalue": "invalid syntax (1766873294.py, line 1)", "output_type": "error", "traceback": [ "\u001b[1;36m Cell \u001b[1;32mIn[13], line 1\u001b[1;36m\u001b[0m\n\u001b[1;33m curl --user \"orHsdvaTglxAGph2bVERUB9W:DIZmXJoRrDkIX8lh66ZORrCmTvSk5zi7kpxMruI1eNfhIDZn\" \"https://api.everypixel.com/v1/keywords?url=http://image.everypixel.com/2014.12/67439828186edc79b9be81a4dedea8b03c09a12825b_b.jpg&num_keywords=10\"\u001b[0m\n\u001b[1;37m ^\u001b[0m\n\u001b[1;31mSyntaxError\u001b[0m\u001b[1;31m:\u001b[0m invalid syntax\n" ] } ], "source": [ "\n", "\n", "curl --user \"orHsdvaTglxAGph2bVERUB9W:DIZmXJoRrDkIX8lh66ZORrCmTvSk5zi7kpxMruI1eNfhIDZn\" \"https://api.everypixel.com/v1/keywords?url=http://image.everypixel.com/2014.12/67439828186edc79b9be81a4dedea8b03c09a12825b_b.jpg&num_keywords=10\"\n", "\n" ] } ], "metadata": { "kernelspec": { "display_name": "sneakpic", "language": "python", "name": "python3" }, "language_info": { "codemirror_mode": { "name": "ipython", "version": 3 }, "file_extension": ".py", "mimetype": "text/x-python", "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", "version": "3.12.2" } }, "nbformat": 4, "nbformat_minor": 2 }