<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Jim Chen on Medium]]></title>
        <description><![CDATA[Stories by Jim Chen on Medium]]></description>
        <link>https://medium.com/@yijunc_54203?source=rss-751639f6d0d4------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/0*P1jVvxiZKT98_JuX</url>
            <title>Stories by Jim Chen on Medium</title>
            <link>https://medium.com/@yijunc_54203?source=rss-751639f6d0d4------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Thu, 03 Dec 2026 20:22:07 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@yijunc_54203/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[How to Create a Pinterest Clone Part III: Display and Searching]]></title>
            <link>https://medium.com/geekculture/how-to-create-a-pinterest-clone-part-iii-display-and-searching-bb1d36e49a0f?source=rss-751639f6d0d4------2</link>
            <guid isPermaLink="false">https://medium.com/p/bb1d36e49a0f</guid>
            <category><![CDATA[pinterest]]></category>
            <category><![CDATA[tigergraph]]></category>
            <dc:creator><![CDATA[Jim Chen]]></dc:creator>
            <pubDate>Sat, 16 Jul 2022 04:02:38 GMT</pubDate>
            <atom:updated>2022-07-16T04:02:38.374Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*GO0G_mlYhvoytRUwW_S_Ag.png" /></figure><p><strong>Overview and Objective</strong></p><p>In the last two blogs (<a href="https://medium.com/geekculture/how-to-create-a-pinterest-clone-part-i-upload-photos-a1f385812729">part 1</a> and <a href="https://medium.com/geekculture/how-to-create-a-pinterest-clone-part-ii-image-classification-1ecf4cca0b20">part 2</a>), we built a web application that includes a webpage for users to upload photos and an API endpoint that tags a photo with a trained neural network, stores the photo file in the MongoDB, and saves the object ID generated by MongoDB along with the tags into the TigerGraph database. In this blog, we will wrap it up by adding two functionalities: display and searching.</p><p><strong>Section I: Implement the backend</strong></p><p>We need two new endpoints in the backend. One will retrieve a photo file from the MongoDB by an object ID, the other will return a list of photo IDs given an optional search text.</p><p>Let’s start with the first one. With the <a href="https://motor.readthedocs.io/en/stable/">Motor</a> module, it is straight forward to get an entry in the MongoDB by the object ID.</p><pre># from bson.objectid import ObjectId<br>####################<br># Connection to MongoDB<br># client = motor.motor_asyncio.AsyncIOMotorClient(&quot;mongodb://localhost:27017&quot;)<br># database = client.photo_manager<br># photo_collection = database.get_collection(&quot;photos&quot;)</pre><pre># Get a specific photo from MongoDB by ID<br>async def retrieve_photo_from_MongoDB(id:str):<br>    try:<br>        entry = await photo_collection.find_one({&quot;_id&quot;: ObjectId(id)})<br>        if entry:<br>            return entry<br>        else:<br>            return False<br>    except:<br>        return False</pre><p>The function’s return value is either False or an entry in the form of {_id: &lt;Object ID&gt;, photo: &lt;Photo file in bytes&gt;} (a python dictionary). We can then use this function in the API endpoint.</p><pre># from fastapi.responses import Response<br># import base64<br>@app.put(&quot;/retrievePhoto/{id}&quot;)<br>async def retrieve_photo(id: str):<br>    data = await retrieve_photo_from_MongoDB(id)<br>    if not data:<br>        return { &quot;code&quot;: 401, &quot;message&quot;: &quot;Failed to get photo.&quot;}<br>    contents = data[&quot;photo&quot;]<br>    contents = base64.b64encode(contents)<br>    return Response(content=contents, media_type=&quot;image/png&quot;)</pre><p>One thing to notice here is that if we transmit raw bytes of a file directly, they may contain reserved bytes for network protocols that interferes with the connection, so we need to encode the bytes with <a href="https://docs.python.org/3/library/base64.html">Base64 data encoding</a>. The result of encoding is also a byte array, and we will pass it back to the frontend without further processing because it is easier to reconstruct the file from encoded bytes in the frontend. The media_type parameter is only a reminder of its true type. We can put media_type=&quot;image/jpeg&quot; or some other types.</p><p>Another thing to notice is that we need to add some CORS settings in order to return a media typed response.</p><pre># from fastapi.middleware.cors import CORSMiddleware<br>####################<br># API endpoints</pre><pre># app = FastAPI()<br>app.add_middleware(<br>    CORSMiddleware,<br>    allow_origins=[&quot;*&quot;],<br>    allow_credentials=True,<br>    allow_methods=[&quot;*&quot;],<br>    allow_headers=[&quot;*&quot;],<br>)</pre><p>Let’s move on to the other endpoint that can return a list of photo IDs for a search text, and we will write a query on TigerGraph to help with this!</p><p>You can go to the TigerGraph Cloud Portal at <a href="https://tgcloud.io/">https://tgcloud.io/</a>, log in your account, start your solution, and open the GraphStudio as we did last time.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*nqpapoHgnXC4gSFnjvH-Yw.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*UnLNW8G_Yq_8NRjPHpT1rA.png" /></figure><p>Then, switch to the ‘photos’ graph on the top-left corner, click on the ‘Write Queries’ tab, and create a new query with the ‘+’ button.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*LMwnNG7JSaXwn-azwghr6g.png" /></figure><p>In the pop-up window, enter FetchAllPhotos for the name and click CREATE.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*9bwCCrE-s3BdcXiz41dFZA.png" /></figure><p>Replace the default query content with the code below.</p><pre>CREATE QUERY FetchAllPhotos(STRING text, FLOAT threshold) FOR GRAPH photos { <br>  STRING pattern = &quot;%&quot; + lower(text) + &quot;%&quot;;<br>  seed = SELECT u FROM Type:u WHERE lower(u.name) LIKE pattern;<br>  result = SELECT v FROM seed:u - (PHOTO_HAS_TYPE:e) - Photo:v<br>            WHERE e.probability &gt;= threshold;<br>  PRINT result;<br>}</pre><p>Basically, it is a <a href="https://docs.tigergraph.com/gsql-ref/current/querying/query-operations">GSQL query</a> that takes two parameters (the search text and a threshold of probability), finds all Type vertexes that have names similar to the search text, and returns all Photo vertexes that are connected to one of such types with probability greater than the threshold. If the parameter text is an empty string, all the types will be accepted.</p><p>There are much more things that we can accomplish with the GSQL language, such as sorting and filtering. If you are interested, please check out <a href="https://docs.tigergraph.com/gsql-ref/current/querying/select-statement/">this doc</a> for more examples!</p><p>Now we can save, install, and run the query with buttons on the top bar! Feel feel to test it with different inputs once your TigerGraph database is populated with some data.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*3U8pBma_A3IGEObLYm1Uww.png" /></figure><p>With the query installed on the TigerGraph database, we are ready to complete the last API endpoint. We need a function to run the query and return a list of object IDs that corresponds to photos to show.</p><pre>async def retrieve_all_photo_info_from_TigerGraph(text: str):<br>    try:<br>        threshold = 0.5<br>        results = conn.runInstalledQuery(&quot;FetchAllPhotos&quot;, params={<br>            &quot;text&quot;: text,<br>            &quot;threshold&quot;: threshold<br>        })<br>        ret = []<br>        for photo_info in results[0][&quot;result&quot;]:<br>            ret.append(photo_info[&quot;attributes&quot;][&quot;id&quot;])<br>        return ret<br>    except:<br>        return False</pre><p>We empirically set a threshold of 0.5 so that if a user searches ‘shirt’, only photos that are classified as shirts with probability higher that 50% will be shown. We can then implement the API endpoint easily.</p><pre># from typing import Union<br>@app.put(&quot;/retrieveAllPhotoInfo&quot;)<br>async def retrieve_all_photo_info(text: Union[str, None] = None):<br>    if text is None:<br>        data = await retrieve_all_photo_info_from_TigerGraph(&quot;&quot;)<br>    else:<br>        data = await retrieve_all_photo_info_from_TigerGraph(text)<br>    if not data:<br>        return { &quot;code&quot;: 401, &quot;message&quot;: &quot;Failed to retrieve photo&quot;}<br>    else:<br>        return { &quot;code&quot;: 200, &quot;data&quot;: data, &quot;message&quot;: &quot;Photo fetched&quot; }</pre><p>Just notice that the search text might be empty (or None), in which case we would display all photos.</p><p>Now you’ve completed the entire backend for this project! The full code is given below.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/daf30b566094caeab38c3f924eef3503/href">https://medium.com/media/daf30b566094caeab38c3f924eef3503/href</a></iframe><p><strong>Section II: Implement the frontend</strong></p><p>We will add two components to the frontend: the search bar and the display section. The search bar is simple with the Quasar framework.</p><pre>&lt;div&gt;<br>  &lt;q-input<br>    outlined<br>    v-model=&quot;searchText&quot;<br>    label=&quot;Search&quot;<br>    debounce=&quot;500&quot;<br>    class=&quot;text-body1 text-weight-bolder&quot;<br>    @update:model-value=&quot;retrieveAllPhotos()&quot;<br>  &gt;<br>    &lt;template v-slot:prepend&gt;<br>      &lt;q-icon name=&quot;search&quot; /&gt;<br>    &lt;/template&gt;<br>  &lt;/q-input&gt;<br>&lt;/div&gt;</pre><p>It would look like this:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*11JNcp38h-EzdlM_D9YZVg.png" /></figure><p>We store the input in the variable searchText, and will refresh the display section with function retrieveAllPhotos (not implemented yet) every time the input changes.</p><p>For the display section, we will show all the photos stored in the libraryPhotoURLs array, which is an array of <a href="https://developer.mozilla.org/en-US/docs/Web/HTTP/Basics_of_HTTP/Data_URLs">Data URLs</a> generated from the photo files. The libraryPhotoURLs array is refreshed by the function retrieveAllPhotos. The photos’ sizes are varied due to the function getSize(), which randomly returns a class among card-small, card-medium, and card-large.</p><pre>&lt;div class=&quot;library-content&quot;&gt;<br>  &lt;div <br>    v-for=&quot;idx in libraryPhotoURLs.length&quot; <br>    :key=&quot;idx&quot; <br>    :class=&quot;getSize()&quot;<br>  &gt;<br>    &lt;div class=&quot;pin-modal&quot;&gt;<br>      &lt;div class=&quot;modal-head&quot;&gt;<br>        &lt;div class=&quot;save-card&quot;&gt;Save&lt;/div&gt;<br>      &lt;/div&gt;<br>    &lt;/div&gt;<br>    &lt;div class=&quot;pin-photo&quot;&gt;<br>      &lt;img<br>        :src=&quot;libraryPhotoURLs[idx-1]&quot; <br>        style=&quot;opacity: 1; <br>        max-width: 100%;&quot; <br>      /&gt;<br>    &lt;/div&gt;<br>  &lt;/div&gt;<br>&lt;/div&gt;</pre><p>We use the CSS Grid Layout and the hover effects to replicate the style of Pinterest. The CSS code related to this part is given below.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/9eaa4087815adc4c9c1bbbf8eb06ec8d/href">https://medium.com/media/9eaa4087815adc4c9c1bbbf8eb06ec8d/href</a></iframe><p>The function retrieveAllPhotos makes a request to the backend to get an array of object IDs that corresponds to all photos to show, sets libraryPhotoURLs as a new empty array of the same length, and calls the function retrievePhoto for each photo.</p><pre>retrieveAllPhotos(){<br>  const api = axios.create({ baseURL: &#39;http://localhost:8000&#39; });<br>  api.put(`/retrieveAllPhotoInfo?text=${this.searchText}`, {})<br>    .then((resp)=&gt;{<br>      // an array of object IDs<br>      const all_photo_info = resp.data.data;<br>      this.libraryPhotoURLs = (new Array(all_photo_info.length)).fill(&#39;&#39;);<br>      for(let i=0;i&lt;all_photo_info.length;i++) {<br>        this.retrievePhoto(all_photo_info[i], i);<br>      }<br>    })<br>    .catch((err)=&gt;{<br>      console.log(err);<br>    });<br>}</pre><p>The function retrievePhoto requests the base64 encoded photo bytes from the backend by the object ID, decodes the bytes into a buffer, reconstructs the photo file, generates the Data URL, and stores it at the indicated index of the libraryPhotoURLs array.</p><pre>retrievePhoto(id:string, idx:number){<br>  const api = axios.create({ baseURL: &#39;http://localhost:8000&#39; });<br>  api.put(`/retrievePhoto/${id}`, {})<br>    .then((resp)=&gt;{<br>      const buff = Buffer.from(resp.data, &#39;base64&#39;);<br>      const blob = new Blob([buff], { type: &#39;image/png&#39; });<br>      const photo = new File([blob], &#39;test&#39;, { type: &#39;image/png&#39; });<br>      const reader = new FileReader();<br>      reader.onload = (e) =&gt; {<br>        this.libraryPhotoURLs[idx] = e.target?.result as string;<br>      };<br>      reader.readAsDataURL(photo as File);<br>    })<br>    .catch((err)=&gt;{<br>      console.log(err)<br>    });<br>}</pre><p>All the changes in frontend are made in frontend/src/pages/IndexPage.vue, we put the full code of this file <a href="https://github.com/JimChen2002/photo-library-part3/blob/master/frontend/src/pages/IndexPage.vue">here</a>.</p><p><strong>Section III: Summary and Resources</strong></p><p>Congratulations on completing this blog series! You can run the application, find some photos of clothes, and upload them to this application. As a reminder, you can run the application by typing these in the terminal:</p><pre># Start the frontend<br>$ cd photo_library/frontend<br>$ quasar dev</pre><pre># Start the backend<br>$ cd photo_library/backend<br>$ source venv/bin/activate<br>$ python3 main.py</pre><pre># Remember to start the TigerGraph solution and the MongoDB service</pre><p>Hope you get the same result as in this picture:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*4ACKxT22YyjEN1xbaZx32Q.png" /></figure><p>In this blog series, you’ve learned how to do these things:</p><ul><li>Build a frontend application with the Pinterest’s styles</li><li>Build a backend server with the image classification model</li><li>Set up and interact with the TigerGraph and the MongoDB</li></ul><p>Armed with these skills, you can start on other full-stack or machine learning projects more easily!</p><p>All the code for this project is uploaded <a href="https://github.com/JimChen2002/photo-library-part3">here</a> with instructions to run it. Feel free to join the<a href="https://discord.com/invite/tigergraph"> TigerGraph Discord</a> and the <a href="https://dev.tigergraph.com/forum/">Developer Forum</a> if you have any questions!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=bb1d36e49a0f" width="1" height="1" alt=""><hr><p><a href="https://medium.com/geekculture/how-to-create-a-pinterest-clone-part-iii-display-and-searching-bb1d36e49a0f">How to Create a Pinterest Clone Part III: Display and Searching</a> was originally published in <a href="https://medium.com/geekculture">Geek Culture</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[How to Create a Pinterest Clone Part II: Image Classification]]></title>
            <link>https://medium.com/geekculture/how-to-create-a-pinterest-clone-part-ii-image-classification-1ecf4cca0b20?source=rss-751639f6d0d4------2</link>
            <guid isPermaLink="false">https://medium.com/p/1ecf4cca0b20</guid>
            <category><![CDATA[pinterest]]></category>
            <category><![CDATA[tigergraph]]></category>
            <dc:creator><![CDATA[Jim Chen]]></dc:creator>
            <pubDate>Wed, 06 Jul 2022 22:02:46 GMT</pubDate>
            <atom:updated>2022-07-06T22:02:46.776Z</atom:updated>
            <content:encoded><![CDATA[<h4>A basic image classification workflow with TensorFlow and the <strong>Python</strong> Imaging Library</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*9TlYWTEkEI9lAi-1wdWGaw.png" /></figure><p><strong>Overview and Objective</strong></p><p>In the <a href="https://medium.com/geekculture/how-to-create-a-pinterest-clone-part-i-upload-photos-a1f385812729">last blog</a>, we built a web page that can upload images and created an API endpoint that can receive these images and store the files in the MongoDB and the metadata in TigerGraph. In this blog, we will integrate a basic image classification workflow built with TensorFlow and the Python Imaging Library into the API endpoint to tag the images and store the tags into TigerGraph. These tags can then be used for searching.</p><p><strong>Section I: The Basic Image Classification Model with TensorFlow</strong></p><p>The actual image classification algorithm used by Pinterest is complicated and beyond the scope of this blog. We will follow the instructions in <a href="https://www.tensorflow.org/tutorials/keras/classification">this doc</a> to train a simple neural network model that can classify images of clothing. It uses the <a href="https://github.com/zalandoresearch/fashion-mnist">Fashion MNIST</a> dataset which contains 70,000 grayscale images (28 by 28 pixels) in 10 categories. Here are some examples:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/840/1*GNLB2jtcfb_xTqgQd9ntJA.png" /><figcaption><a href="https://github.com/zalandoresearch/fashion-mnist">Fashion-MNIST samples</a> (by Zalando, MIT License).</figcaption></figure><p>We need to install TensorFlow first. Remember to activate the virtual environment so that it doesn’t mess up our local environment.</p><pre>$ cd photo_library/backend<br>$ source venv/bin/activate</pre><p>Then we can run this command to install TensorFlow (MacOS only, please refer to <a href="https://www.tensorflow.org/install/pip#macos">this doc</a> for other systems).</p><pre># the only package installed with pip<br>$ python3 -m pip install tensorflow</pre><p>Let’s start create a Python program at to train and save the model!</p><pre># photo_library/backend/ML.py<br>import tensorflow as tf<br>import numpy as np</pre><p>After importing the modules, we will load the Fashion-MNIST dataset.</p><pre>fashion_mnist = tf.keras.datasets.fashion_mnist<br>(train_images, train_labels), (test_images, test_labels) = fashion_mnist.load_data()<br>class_names = [&#39;T-shirt/top&#39;, &#39;Trouser&#39;, &#39;Pullover&#39;, &#39;Dress&#39;, &#39;Coat&#39;, &#39;Sandal&#39;, &#39;Shirt&#39;, &#39;Sneaker&#39;, &#39;Bag&#39;, &#39;Ankle boot&#39;]</pre><p>There are 60,000 training images and 10,000 test images. Each image has a corresponding label that is a number from 0 to 9, representing a class name (e.g. 0 for T-shirt/top and 9 for ankle boot). To be more precise, the variable train_images is a numpy array of size 60000*28*28, which represents 60,000 images each with 28*28 pixels of value 0 to 255, and the variable train_labels is a numpy array of size 60000, where each element takes a value from 0 to 9, representing the class name of each image.</p><p>Since the neural network model works best with numbers from 0 to 1, we need to normalize the pixel values from 0–255 to 0–1.</p><pre>train_images = train_images / 255.0<br>test_images = test_images / 255.0</pre><p>Then, we can train and save the model.</p><pre>model = tf.keras.Sequential([<br>    tf.keras.layers.Flatten(input_shape=(28, 28)),<br>    tf.keras.layers.Dense(128, activation=&#39;relu&#39;),<br>    tf.keras.layers.Dense(10)<br>])<br>model.compile(optimizer=&#39;adam&#39;, loss=tf.keras.losses.SparseCategoricalCrossentropy(from_logits=True), metrics=[&#39;accuracy&#39;])<br>model.fit(train_images, train_labels, epochs=10)<br>model.save(&#39;my_model&#39;)</pre><p>Basically, we chain several layers to create the model, compile the model with some recommended parameters, fit (or train) the model, and save the model to the given path. For a detailed description of each component, please check out <a href="https://www.tensorflow.org/tutorials/keras/classification">this doc</a>. For a high-level conceptual understanding, I would highly recommend <a href="https://youtu.be/aircAruvnKk">this video series</a> by 3Blue1Brown.</p><p>We can now run the program.</p><pre># a terminal at photo_library/backend<br>$ python3 ML.py</pre><p>It will take less than 30 seconds for a regular Mac. No GPU needed! We can evaluate the model with the test dataset by adding the following two lines to the end of the program.</p><pre>test_loss, test_acc = model.evaluate(test_images, test_labels)<br>print(&#39;\nTest accuracy:&#39;, test_acc)</pre><p>The model will be used to predict the class (a number from 0 to 9) of each test image, and the predictions will be compared with the actual labels to get an accuracy, which will be around 90%. Although we use a small dataset and a simple model, the result is quite good!</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*NTUV-JSY5IIn61GkzD5Xvw.png" /><figcaption>The terminal output after we ran the program</figcaption></figure><p>We now have a basic image classification model! As a recap for this section, we put the following code at photo_library/backend/ML.py and ran it, which trained an image classification model and saved it at photo_library/backend/my_model.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/4fcb588d405c3ad6b809053cca40c7a2/href">https://medium.com/media/4fcb588d405c3ad6b809053cca40c7a2/href</a></iframe><p><strong>Section II: Integrate the Image Classification Model into the server</strong></p><p>Currently, we have an API endpoint that stores the user uploaded photo file into MongoDB, generates an object ID, and puts the object ID into TigerGraph.</p><pre># main.py<br>@app.post(&quot;/uploadPhoto/&quot;)<br>async def upload_photo(file: UploadFile):<br>    contents = await file.read()<br>    # add to MongoDB<br>    data = { &quot;photo&quot;: contents }<br>    photoID = await add_photo_to_MongoDB(data)<br>    # <strong>TODO:</strong> tag the photo with the model<br>    success = await add_photo_id_to_TigerGraph(photoID)<br>    if success:<br>        return { &quot;code&quot;: 200, &quot;message&quot;: &quot;Photo uploaded&quot;}<br>    else:<br>        return { &quot;code&quot;: 401, &quot;message&quot;: &quot;Failed to add photo&quot;}</pre><p>Now we want to tag the photo with the model and add the metadata to the TigerGraph database. First, we need to turn the photo file into an Image object and process it with Python Imaging Library (PIL).</p><pre># import uuid<br># from PIL import Image<br># import matplotlib.pyplot as plt</pre><pre># All the code below is added to the <strong>TODO</strong> position</pre><pre>unique_file_path = str(uuid.uuid4()) + file.filename<br>with open(unique_file_path, &#39;wb&#39;) as f:<br>    f.write(contents)<br>img=Image.open(unique_file_path)<br>os.remove(unique_file_path)<br># Show the image in a pop-up window<br>plt.imshow(img)<br>plt.show()</pre><p>After we add the dependencies and code, we can run our project and try to upload an image.</p><pre># Start the frontend<br>$ cd photo_library/frontend<br>$ quasar dev</pre><pre># Start the backend<br>$ cd photo_library/backend<br>$ source venv/bin/activate<br>$ python3 main.py</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*rhD76PxyOM2MTKKVT2Dx6Q.png" /><figcaption>Shirt Image from <a href="https://pixabay.com/vectors/shirt-pink-t-shirt-jersey-tee-34238/">Pixabey</a></figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*PejskZbSs6Aq6eQkw9KG3A.png" /><figcaption>Shirt Image in a Pop-up Window</figcaption></figure><p>The photo is loaded as an Image object, and we need to transform it into a grayscale images of size 28 by 28 pixels.</p><pre># Resize the image to 28*28 with bilinear interpolation<br>small_img=img.resize((28,28),Image.Resampling.BILINEAR)<br># Show the image<br>plt.imshow(small_img)<br>plt.show()</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*jZbFurfmE9x-cFAoNjTIHA.png" /><figcaption>Resized Shirt</figcaption></figure><pre># Turn the image into Black &amp; White<br>BW_small_img=small_img.convert(&quot;L&quot;)<br># Show the image<br>plt.imshow(BW_small_img)<br>plt.colorbar()<br>plt.show()</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*KqesxpWnDerc6z-qWn5lxw.png" /><figcaption>Grayscale, 28 by 28 pixels image with pixel value from 0 to 255</figcaption></figure><p>Then, we convert the image pixels into a normalized Numpy array.</p><pre># import numpy as np<br>pix = np.array(BW_small_img)<br>img = np.expand_dims(pix,0) / 255.0</pre><p>We load the trained model and use it to predict the class of the image.</p><pre># import tensorflow as tf<br>model = tf.keras.models.load_model(&#39;my_model&#39;)<br>probability_model = tf.keras.Sequential([model, tf.keras.layers.Softmax()])<br>predictions = probability_model.predict(img)<br>print(predictions)</pre><p>After removing the code that shows image, let’s run it and see the predictions!</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*blLtrB-ZnuOL4m1fGSJaow.png" /></figure><p>There are 10 numbers from 0 to 1, which represents the probability that the image belongs to a certain class. Recall that the 10 classes are these:</p><pre>class_names = [&#39;T-shirt/top&#39;, &#39;Trouser&#39;, &#39;Pullover&#39;, &#39;Dress&#39;, &#39;Coat&#39;, &#39;Sandal&#39;, &#39;Shirt&#39;, &#39;Sneaker&#39;, &#39;Bag&#39;, &#39;Ankle boot&#39;]</pre><p>We can see that ‘Shirt’ has the highest probability of 0.74, and ‘T-shirt/top’ has the second highest probability of 0.26, which is reasonable!</p><p>As a recap, you can put the following code in photo_library/backend/main.py. The API endpoint will now print a prediction array for every uploaded photo.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/adb1d617d5ce376e39ec510b3f9fcfec/href">https://medium.com/media/adb1d617d5ce376e39ec510b3f9fcfec/href</a></iframe><p><strong>Section III: Store the metadata in TigerGraph</strong></p><p>In the last blog, we created the ‘Photo’ vertex in TigerGraph. Now we will add a ‘Type’ vertex and an edge ‘PHOTO_HAS_TYPE’ to store the metadata.</p><p>Let’s navigate to <a href="https://tgcloud.io/">https://tgcloud.io/</a>, log in with the credentials, and go to the ‘My Solutions’ tab.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*nqpapoHgnXC4gSFnjvH-Yw.png" /></figure><p>Start the solution that we created, which will take around a minute, and open the GraphStudio.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*UnLNW8G_Yq_8NRjPHpT1rA.png" /></figure><p>Switch to ‘photos’ graph, navigate to ‘Design Schema’, and click on the ‘+’ button to add the ‘Type’ vertex with the primary id called ‘name’, which has type string and is stored as an attribute.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*NNgOOcoTOdSQsVHI-DiXaQ.png" /></figure><p>Then, we can click on the right arrow button to add the ‘PHOTO_HAS_TYPE’ edge. The configuration includes the source vertex ‘Photo’, the target vertex ‘Type’, and an attribute ‘probability’ of type float.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*x3G0aEglb4xOZRYgvR6gEg.png" /></figure><p>Finally, we click on the top left button to ‘Publish schema’, and our TigerGraph solution is good to go!</p><p>In main.py, we can update the function that takes a photo ID and inserts it into TigerGraph to add the photo’s metadata.</p><pre>async def add_photo_id_with_predictions_into_TigerGraph(id: str, predictions: list):<br>    try:<br>        class_names = [&#39;T-shirt&#39;, &#39;Trouser&#39;, &#39;Pullover&#39;, &#39;Dress&#39;, &#39;Coat&#39;, &#39;Sandal&#39;, &#39;Shirt&#39;, &#39;Sneaker&#39;, &#39;Bag&#39;, &#39;Ankle-boot&#39;]<br>        conn.upsertVertex(&quot;Photo&quot;, id, {})<br>        # only need to insert type vertexes once<br>        for name in class_names:<br>            conn.upsertVertex(&quot;Type&quot;, name, {})<br>        threshold = 0.01<br>        for idx, probability in enumerate(predictions):<br>            if probability &gt;= threshold:<br>                conn.upsertEdge(&quot;Photo&quot;, id, &quot;PHOTO_HAS_TYPE&quot;, &quot;Type&quot;, class_names[idx], {&quot;probability&quot;: probability})<br>        return True<br>    except:<br>        return False</pre><p>We insert the ‘Photo’ vertex with an object ID that refers to the photo file stored in MongoDB, add all the ‘Type’ vertexes, and add edges with a probability that indicates the possibility that each photo belongs to a class. We only need to insert the ‘Type’ vertexes once, so feel free to remove or comment out the two lines of code once ‘Type’ vertexes are inserted. We also include a threshold for possibility to reduce redundant edges.</p><p>Let’s use this function in the API endpoint, and the code would look like this:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/7ec14cc4fbf93024fda5c719e6b3a840/href">https://medium.com/media/7ec14cc4fbf93024fda5c719e6b3a840/href</a></iframe><p>If we run the project and upload the pink shirt photo again, we will see it in the MongoDB.</p><pre># As a reminder of how to run the project<br># Start the frontend<br>$ cd photo_library/frontend<br>$ quasar dev</pre><pre># Start the backend<br>$ cd photo_library/backend<br>$ source venv/bin/activate<br>$ python3 main.py</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*5LogbpO04NCk-mGkJEusGg.png" /></figure><p>We can copy its object ID and search it in TigerGraph.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*olyy37asfmXBrbPcEilkJw.png" /></figure><p>It is connected to ‘Shirt’ and ‘T-shirt’ with probability 0.74 and 0.26, which is exactly what we expected!</p><p><strong>Section IV: Next Steps and Resources</strong></p><p>That’s all for this part! All the code is uploaded <a href="https://github.com/JimChen2002/photo-library-part2">here</a> with instructions to run it. If you are especially interested in some technologies used in this blog, here are the links to their documentations: <a href="https://docs.tigergraph.com/cloud/start/overview">TigerGraph Cloud</a>, <a href="https://www.mongodb.com/docs/manual/administration/install-community/">MongoDB Setup</a>, <a href="https://fastapi.tiangolo.com/">FastAPI</a>, and <a href="https://quasar.dev/">Quasar</a>.</p><p>We will wrap it up in the next part by completing the frontend with searching. Feel free to join the<a href="https://discord.com/invite/tigergraph"> TigerGraph Discord</a> and the <a href="https://dev.tigergraph.com/forum/">Developer Forum</a> if you have any questions!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=1ecf4cca0b20" width="1" height="1" alt=""><hr><p><a href="https://medium.com/geekculture/how-to-create-a-pinterest-clone-part-ii-image-classification-1ecf4cca0b20">How to Create a Pinterest Clone Part II: Image Classification</a> was originally published in <a href="https://medium.com/geekculture">Geek Culture</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[How to Create a Pinterest Clone Part I: Upload Photos]]></title>
            <link>https://medium.com/geekculture/how-to-create-a-pinterest-clone-part-i-upload-photos-a1f385812729?source=rss-751639f6d0d4------2</link>
            <guid isPermaLink="false">https://medium.com/p/a1f385812729</guid>
            <category><![CDATA[pinterest]]></category>
            <category><![CDATA[tigergraph]]></category>
            <dc:creator><![CDATA[Jim Chen]]></dc:creator>
            <pubDate>Thu, 30 Jun 2022 18:02:40 GMT</pubDate>
            <atom:updated>2022-06-30T18:02:40.985Z</atom:updated>
            <content:encoded><![CDATA[<h4>A photo hosting service with image classification and searching powered by TigerGraph</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*4ACKxT22YyjEN1xbaZx32Q.png" /><figcaption>The preview of the final product</figcaption></figure><p><strong>Overview and Objective</strong></p><p>Pinterest is a billion-dollar company with growing number of users. One of the technologies that sets Pinterest apart was introduced by Jure Leskovec, the chief scientist at Pinterest and professor at Stanford University, in <a href="https://info.tigergraph.com/graph-ai-summit-spring-2021-jure-leskovec">this video</a>, where he talks about how Pinterest uses graph information of billions of pins and boards to empower AI and provide more relevant recommendations and searching results. Pins alone can generate a graph, where photos are connected to common metadata. This graph information can also be used to obtain better searching results.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/734/1*t4BDcdK4cx3hwBYm3etzZw.png" /><figcaption>Example of the metadata in a picture (Image from <a href="https://pixabay.com/illustrations/cat-cat-and-mouse-cute-cute-cat-3552048/">Pixabay</a>)</figcaption></figure><p>This blog series will show you step-by-step how to build a Pinterest clone that identifies the metadata of user uploaded photos with basic image classification algorithm and uses the metadata with TigerGraph to empower searching. We will use Quasar for the frontend, FastAPI for the backend, MongoDB to store the photo files, and TigerGraph to store the photo metadata and empower searching. By the end of this blog (Part I), you will have built a web application that supports photo uploading with a preview. Feel free to refer to the code posted for both frontend and backend after each step!</p><p><strong>Prerequisites:</strong></p><p>Basic familiarity with Typescript, Python, and MongoDB are recommended but not necessary! Feel free to explore only parts that you are interested in and copy the code for other parts!</p><p><strong>Section I: Create the frontend, backend, and database</strong></p><p>Let’s start by creating a directory called photo_library that will contain everything for this project. We will first create our frontend directory with <a href="https://quasar.dev/start/quasar-cli">Quasar-CLI</a>. Open a terminal at photo_library<em> </em>and enter:</p><pre>$ yarn global add @quasar/cli <br>$ yarn create quasar</pre><pre># or:  </pre><pre>$ npm i -g @quasar/cli <br>$ npm init quasar</pre><p>If you haven’t installed yarn and npm, it is recommended to install npm. Please refer to <a href="https://docs.npmjs.com/downloading-and-installing-node-js-and-npm">the docs here</a>!</p><p>It will install Quasar-CLI with yarn or npm and start creating a quasar app. When prompted to enter the configuration, please refer to:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*6OpTbja7W8v-xfz72Ugr2Q.png" /></figure><p>Cool! It will create the directoryphoto_library/frontend. Now let’s open it in VSCode (or your favorite code editor). If we run $ quasar dev, we will see the default Quasar page shown on <a href="http://localhost:8080/#/">http://localhost:8080/#/</a>. Let’s change it into a template page for this project. We can put the following code in src/pages/IndexPage.vue and src/layouts/MainLayout.vue respectively.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/9f47b8fcb2aa5446e60604e53905c6e0/href">https://medium.com/media/9f47b8fcb2aa5446e60604e53905c6e0/href</a></iframe><p>If we run $ quasar dev now, we will see a page as follows:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*jZFczjefIJ0d4JiCYL0nGA.png" /></figure><p>Good job! It already looks (kind of) close to our final product.</p><p>We will send API requests to the backend using the ‘axios’ package. Let’s navigate to photo_library/frontend and add &quot;axios&quot;: &quot;0.27.2&quot; in &quot;dependencies&quot; of package.json.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*5NtSWhr1XWZnzfE-ouoYMA.png" /></figure><p>Then, we can run</p><pre>$ yarn<br># or:<br>$ npm install</pre><p>to install the ‘axios’ package.</p><p><strong>All the subsequent code changes will be in </strong><strong>src/pages/IndexPage.vue </strong>and we will approach our final product iteratively.</p><p>Let’s move on to our backend. If you haven’t installed python3, please refer to <a href="https://docs.python-guide.org/starting/install3/osx/">this</a> if you are on Mac, or <a href="https://docs.python.org/3/using/windows.html">this</a> if you are on Windows.</p><p>We will start by creating the directory photo_library/backend and two files, main.py and requirements.txt, in it. We then put some initial code in them:</p><pre># main.py<br>import uvicorn<br>from fastapi import FastAPI</pre><pre>app = FastAPI()</pre><pre>@app.get(&quot;/&quot;)<br>async def root():<br>    return {&quot;message&quot;: &quot;Hello World&quot;}</pre><pre>if __name__ == &#39;__main__&#39;:<br>    uvicorn.run(&#39;main:app&#39;, reload=True)</pre><p>and</p><pre># requirements.txt<br>fastapi==0.75.2<br>uvicorn==0.15.0<br>pyTigerGraph==0.0.9.9.2<br>motor==2.5.1<br>python-multipart==0.0.5<br>matplotlib==3.5.2</pre><p>For sake of simplicity, the requirement file has all the modules that will be installed by pip3 in this project (the only one left is tensorflow, we will install it with pip later). So that we don’t mess up our local environment, we will use a virtual environment to install the modules. In a terminal at photo_library/backend, let’s run:</p><pre>$ python3 -m venv venv<br>$ source venv/bin/activate</pre><p>We will see (venv) showing up at the beginning of the terminal prompt line. It means that our terminal is operating in the virtual environment. Please remember to run $ source venv/bin/activate every time you close and reopen the terminal.</p><p>Then, we can run</p><pre>$ pip3 install -r requirements.txt</pre><p>to install the modules, which will take less than a minute. After that, we run</p><pre>$ python3 main.py</pre><p>It will start our backend with the first API endpoint listening on <a href="http://localhost:8000/">http://localhost:8000/</a>:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*O5MbTBvRhgz7gFqgtaVRMA.png" /></figure><p>Great! We have a working FastAPI backend server now.</p><p>We will use MongoDB and TigerGraph to store data.</p><p>For MongoDB, we can refer to <a href="https://www.mongodb.com/docs/manual/administration/install-community/">this guide</a> for the installation and setup of MongoDB Community Edition, and also install <a href="https://www.mongodb.com/try/download/compass">Compass</a>, which is the Graphic User Interface (GUI) of MongoDB. After that, open up Compass and click on the button <strong>Connect</strong> which creates a connection to MongoDB. On the resulting page, click on the <strong>Databases</strong> tab and click on <strong>Create database</strong>, then enter <strong>photo_library</strong> for database name and <strong>photos</strong> for collection name. Then, we are good with MongoDB!</p><p>For TigerGraph, we can refer to <a href="https://docs.tigergraph.com/cloud/solutions/create">this documentation</a> to create our TigerGraph cloud solution. It is a cloud graph database with user-friendly GUI, and it can be used for free! During setup, remember to <strong>keep note of your initial password and subdomain!</strong> We will usephoto-library.i.tgcloud.io as our subdomain and tigergraph as our password. The solution used for this blog will have already been terminated by the time of publication. Please create a solution with a more secure password.</p><p>Once the solution is created, we will click on the start button:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*nqpapoHgnXC4gSFnjvH-Yw.png" /><figcaption>Please notice that the solution will automatically stop after 1 hour of inactivity, but you can restart it anytime</figcaption></figure><p>Once started, we can open GraphStudio to create the graph and write queries!</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*UnLNW8G_Yq_8NRjPHpT1rA.png" /></figure><p>Enter the username (default: tigergraph) and password (the initial password you just set for your solution) to log in to GraphStudio. Then click on Global View in the upper left corner and create a graph called ‘photos’.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*9CL5FNT2hf9f2ujpG9US1w.png" /><figcaption>Click on ‘Create a Graph’ (The graph ‘photos’ is already created in this example solution)</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*9lzUscuyHX0pH6xOu16Dcw.png" /><figcaption>Enter the name of the graph</figcaption></figure><p>Then switch to the graph ‘photos’ by clicking on ‘Global View’ and then ‘photos’ in the drop-down list. Click on the tab ‘Design Schema’ to create a vertex for our graph.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*-7RxHxpt3ozO3XykYijqRA.png" /><figcaption>Click on the button marked red in the upper left corner to add a local vertex type, then edit the vertex type as shown in the image. (You will not see the warning. It is a spoiler for a later part of this blog.)</figcaption></figure><p>We will create a vertex type ‘Photo’ with an attribute ‘id’ that stores the object ID of a photo stored in MongoDB. Although storing the object ID alone in TigerGraph isn’t useful for now, it will empower searching when combined with tags that we will generate with the image classification algorithm in a later part.</p><p>After the changes, click on the ‘Publish schema’ button to the left of the ‘Add local vertex type’ button, wait for the changes to be committed, and our TigerGraph solution is good to go!</p><p>Congratulations on setting up the development environment! Let’s have a short break and then move on to implement the photo hosting service!</p><p><strong>Section II: Implement the photo hosting service</strong></p><p>Let’s start with the backend. We need an API endpoint that takes a photo in the form data as input, stores the photo bytes in a document of MongoDB, and stores the document’s object ID in TigerGraph.</p><p>The API endpoint would look like this:</p><pre># from fastapi import UploadFile<br>@app.post(&quot;/uploadPhoto/&quot;)<br>async def upload_photo(file: UploadFile):<br>    contents = await file.read()<br>    # add photo to MongoDB<br>    data = { &quot;photo&quot;: contents }<br>    photoID = await <strong>add_photo_to_MongoDB</strong>(data)<br>    # add photoID TigerGraph<br>    success = await <strong>add_photo_id_to_TigerGraph</strong>(photoID)<br>    if success:<br>        return { &quot;code&quot;: 200, &quot;message&quot;: &quot;Photo uploaded&quot;}<br>    else:<br>        return { &quot;code&quot;: 401, &quot;message&quot;: &quot;Failed to add photo&quot;}</pre><p>We then implement the bold functions that interact with databases. We use <a href="https://motor.readthedocs.io/en/stable/">Motor</a> to interact with MongoDB:</p><pre># import motor.motor_asyncio<br>####################<br># Connection to MongoDB<br>client = motor.motor_asyncio.AsyncIOMotorClient(&quot;mongodb://localhost:27017&quot;)<br>database = client.<strong>photo_library</strong><br>photo_collection = database.get_collection(&quot;<strong>photos</strong>&quot;)</pre><pre># Add a new photo to MongoDB<br>async def add_photo_to_MongoDB(photo_data:dict):<br>    try:<br>        entry = await photo_collection.insert_one(photo_data)<br>        return str(entry.inserted_id) <br>    except:<br>        return False</pre><p>Notice that the bold variables refer to the database name and collection name we used earlier. You can change them if you used different names.</p><p>We will use pyTigerGraph to interact with TigerGraph. Please change the host and password to your own.</p><pre># import pyTigerGraph as tg<br>####################<br># Connection to TigerGraph<br>conn = tg.TigerGraphConnection(<br>    host=&quot;<a href="https://photo-manager.i.tgcloud.io/">https://photo-library.i.tgcloud.io</a>&quot;,<br>    graphname=&quot;photos&quot;,<br>    username=&quot;tigergraph&quot;,<br>    password=&quot;tigergraph&quot;, )<br>conn.apiToken = conn.getToken(conn.createSecret())<br>#conn.apiToken = (&#39;...&#39;, ..., &#39;...&#39;)<br>async def add_photo_id_to_TigerGraph(id: str):<br>    try:<br>        conn.upsertVertex(&quot;Photo&quot;, id, {})<br>        return True<br>    except:<br>        return False</pre><p>There is a little trick to develop with PyTigerGraph: apiToken generation can take several seconds, which can make FastAPI reloading less responsive. If we are constantly changing code, it will be helpful to print out the apiToken once and just set it to the value.</p><p>Put them together, main.py now looks like this:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/9f9d3f651ddee735a1c688bcb3765a00/href">https://medium.com/media/9f9d3f651ddee735a1c688bcb3765a00/href</a></iframe><p>We can start it with python3 main.py (remember to activate the virtual environment with source venv/bin/activate) and visit the documentation page on <a href="http://localhost:8000/docs">http://localhost:8000/docs</a></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*M6RgsCjyXe8ERYE5Wlp6Lg.png" /></figure><p>Expand the tab for the endpoint we just built and click on ‘Try it out’.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*biYztx1ubY39S-loK2qvIg.png" /></figure><p>Then, we can choose a file (less than 16MB) and click on ‘Execute’. If the MongoDB Community Edition and TigerGraph solution are running properly, we can see a new document added in MongoDB and a vertex with the same object ID added in TigerGraph.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*jQm8QiZE3xf90c2-Li9Nlg.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*rM8ILEytu8Gov4zbfepUdw.png" /><figcaption>In GraphStudio, you can switch to the graph ‘photos’, click on ‘Explore Graph’, and search for the vertex</figcaption></figure><p>We have built a working API endpoint to upload and store photos! Let’s finish this part by building up a simple frontend with some styles. We can put the following code in photo_library/frontend/src/pages/IndexPage.vue.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/15bfef8045f21918c2e210cba103f195/href">https://medium.com/media/15bfef8045f21918c2e210cba103f195/href</a></iframe><p>The resulting page will look like this:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*7T4-VK-Y3_XNuv1GqSLiAw.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*O3Q--_biInKxXQwdbxh78g.png" /></figure><p>You can click ‘Pick Photo’ to select a photo and then click ‘Upload’ to send the selected photo to the backend. Feel free to play around with it and check if the changes are reflected in the databases.</p><p>Congratulations on finishing Part 1! All the code is uploaded <a href="https://github.com/JimChen2002/photo-library-part1">here</a> with instructions to run it.</p><p>We will incorporate image classification and searching in later parts. Meanwhile, definitely join the<a href="https://discord.com/invite/tigergraph"> TigerGraph Discord</a> and the <a href="https://dev.tigergraph.com/forum/">Developer Forum</a> if you have any questions!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=a1f385812729" width="1" height="1" alt=""><hr><p><a href="https://medium.com/geekculture/how-to-create-a-pinterest-clone-part-i-upload-photos-a1f385812729">How to Create a Pinterest Clone Part I: Upload Photos</a> was originally published in <a href="https://medium.com/geekculture">Geek Culture</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
    </channel>
</rss>