Code Monkey home page Code Monkey logo

mrisa's Introduction

Mrisa Logo

MRISA


MRISA (Meta Reverse Image Search API) is a RESTful API which takes an image URL, does a reverse Google image search, and returns a JSON array with the search results.

Usage

Install the necessary dependencies:

pip install -r requirements.txt

Or

pip install certifi flask pycurl beautifulsoup4 flask_cors requests lxml

Start the server with:

python src/server.py

There is also a docker image. Please note that this is a work in progress and any amends/fixes would be most welcome (Dockerfile is in the project root)

docker build -t "vivithemage/mrisa:latest" .
docker run -p 5000:5000 mrisa python mrisa/src/server.py

Any issues with pycurl or lxml

If you have any issues relating to pycurl, it's likely dependancies are required.

sudo apt install libcurl4-openssl-dev libssl-dev

That's also the case for lxml.

sudo apt-get install libxml2-dev libxslt1-dev

Please note, these commands for apt based systems only so you will need to find the equivalents for other packaging systems.

API

Perform a Reverse Image Search

Performs a reverse image search using the supplied image URL as input.

URL

Arguments

  • image_url - A URL to an image to use for the search input.

Request Example

CURL

curl -X POST http://localhost:5000/search \
    -H "Content-Type: application/json" \
    -d '{
        "image_url":
            "http://placehold.it/350x150.png",
        "resized_images":false
        }'

XMLHttpRequest

    var xhr = new XMLHttpRequest();

    xhr.open('POST',"http://localhost:5000/search");

    //Important
    xhr.setRequestHeader("Content-Type","application/json");

    data= {
        "image_url":"http://placehold.it/350x150.png",
        "resized_images":false // Or true
        };

    json = JSON.stringify(data);

    xhr.onreadystatechange = gotDetails;

    xhr.send(json);

    var gotDetails = () => {
        //Got The response
        console.log(xhr.responseText);
    };

Python request example

import requests, json

url = "http://localhost:5000/search"

data = {
    "image_url":"http://placehold.it/350x150.png",
    "resized_images":False, # Or True
    "cloud_api":True
}


headers = {'Content-type': 'application/json'}
r = requests.post(url, headers=headers, data=json.dumps(data))

#r.json to get the response as json
print(r.json())

#r.text for no u'' characters

Response Example (for the above request)

Shortened to 3 resized_image objects out of 20

Expand to view
{
    "best_guess": "placeholder img",
    "descriptions": [
        "Just put your image size after our URL and you'll get a placeholder image. Like this: http://via.placeholder.com/350x150. You can also use it in your code, like\u00a0...",
        "Custom URLs generate placeholder pictures in various sizes with categories and effects. ... Use the buttons above to create the type of image you need. You can\u00a0...",
        "689 \u00d7 300 - Apr 5, 2012 - If you're after a quick and easy way to produce flexible placeholder images for your site, check this out!",
        "350 \u00d7 150 - Which Image Formats Work? Placeholder work with GIF, JPEG, JPG or PNG formats. Just add an image extension to render the image in the format you want.",
        "350 \u00d7 150 - Apr 12, 2018 - I want to create an image with dynamic size like placeholder.com, below is the code to create image with golang: width = 350 height = 150 img\u00a0...",
        "350 \u00d7 150 - Apr 12, 2018 - I want to create an image with dynamic size like placeholder.com, below is the code to create image with golang: width = 350 height = 150 img\u00a0...",
        "450 \u00d7 150 - Jan 29, 2018 - packed-img-strip is a jQuery responsive equal height plugin which automatically ... 02, < img src = \"http://via.placeholder.com/300x300\" />\u00a0..."
    ],
    "links": [
        "https://placeholder.com/",
        "https://placeimg.com/",
        "https://premium.wpmudev.org/blog/image-placeholder/",
        "https://digital.com/tools/placeholder-images/",
        "https://stackoverflow.com/questions/49787206/draw-number-like-placeholder-com-with-golang",
        "https://stackoverflow.com/questions/49787206/draw-number-like-placeholder-com-with-golang?noredirect=1&lq=1",
        "https://www.jqueryscript.net/layout/jQuery-Responsive-Equal-Height-Images.html"
    ],
    "resized_images": [
        {
            "cb": 21,
            "cl": 21,
            "cr": 21,
            "ct": 21,
            "id": "6aNqqL0gKIoXoM:",
            "isu": "demos1.softaculous.com",
            "itg": 0,
            "ity": "",
            "oh": 540,
            "ou": "https://placehold.it/1900x540&text=Slide%20One",
            "ow": 1900,
            "pt": "CSZ Home | CSZ CMS Starter",
            "rh": "demos1.softaculous.com",
            "rid": "UG-EsErbGOiH7M",
            "rt": 0,
            "ru": "https://demos1.softaculous.com/CSZ_CMS/",
            "s": "Caption One",
            "sc": 1,
            "st": "Softaculous",
            "th": 119,
            "tu": "https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcT00elB19-tlgLm8Icu1EgDmpiv1hKh1bJsy699M8r4ezFQHMno2Q",
            "tw": 422
        },
        {
            "cb": 21,
            "cl": 21,
            "cr": 21,
            "ct": 21,
            "id": "cESt2PZwCgUg6M:",
            "isu": "eyurtlar.com",
            "itg": 0,
            "ity": "png",
            "oh": 701,
            "ou": "https://www.eyurtlar.com/images/detaygorselyok.png",
            "ow": 1080,
            "pt": "Yakamoz Be\u015fikta\u015f K\u0131z \u00d6\u011frenci Yurdu | Eyurtlar.com",
            "rh": "eyurtlar.com",
            "rid": "tzcWrjUMKPm9bM",
            "rt": 0,
            "ru": "https://www.eyurtlar.com/istanbul-yakamoz-besiktas-kiz-ogrenci-yurdu/580",
            "s": "Yakamoz Be\u015fikta\u015f K\u0131z \u00d6\u011frenci Yurdu",
            "sc": 1,
            "st": "\u0130stanbul \u00d6zel Yurtlar | \u00d6\u011frenci Apart Rehberi",
            "th": 181,
            "tu": "https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcR9LeeXUjP0b9JYWnk8G_6o5Caf8Rm19gQH3H6UISXQoFGBIrIAcg",
            "tw": 279
        },

        # 17 more...

        {
            "cb": 21,
            "cl": 21,
            "cr": 21,
            "ct": 21,
            "id": "DZMVBEHnNZ1t7M:",
            "isu": "feedyeti.com",
            "itg": 0,
            "ity": "",
            "oh": 302,
            "ou": "http://cdn.crownmediadev.com/dims4/default/16e50bf/2147483647/thumbnail/704x436%5E/quality/90/?url=http%3A%2F%2Fbrightcove04.o.brightcove.com%2F3388362517001%2F3388362517001_3868818829001_video-still-for-video-3868909161001.jpg%3FpubId%3D3388362517001",
            "ow": 704,
            "pt": "Feetloaf on FeedYeti.com",
            "rh": "feedyeti.com",
            "rid": "QHJzkyhwHYYHFM",
            "rt": 0,
            "ru": "https://feedyeti.com/hashtag.php?q=Feetloaf",
            "s": "... ?url=http%3A%2F%2Fbrightcove04.o.brightcove.com  48HlyYz0hT69uvLAkMM9HDvtjRDKS ...",
            "sc": 1,
            "st": "FeedYeti.com",
            "th": 147,
            "tu": "https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcQW1P4gS0f1JFBrkkUU5_0spEIOwS50OCPxpYSzj47HinRJLCBi1Q",
            "tw": 343
        }
    ],
    "similar_images": [
        "https://via.placeholder.com/350x150",
        "http://www.dreamlight-music.com/assets/img/demo/g.png",
        "http://hispaniola.co.uk/wp-content/themes/hispaniola/img/placehold_600%20x%20400.png",
        "http://dining-delight.com/img/gallery-img-02.jpg",
        "http://svnit.ac.in/Data/facup/pjengineer/img/gallery/800x600.png",
        "http://fpoimg.com/600x250/For%20Place%20Only%20Image",
        "https://topshoes.ua/themes/topshoes_v2/assets/img/i/banner-2-800x600.jpg",
        "http://www.garywongrealty.com/wp-content/uploads/2017/01/img-placeholder.jpg",
        "http://geniussys.com/img/placeholder/blogposts-300x220.png",
        "https://hartford.uconn.edu/wp-content/uploads/sites/2222/2017/07/placeholder-img.jpg"
    ],
    "titles": [
        "Placeholder.com - Quick & Simple Placeholder Images, Text & More",
        "PlaceIMG | Easy FPO and Dummy Images for Any Project",
        "Quick Tip: The Easiest Image Placeholder Tool I Have Found - WPMU ...",
        "Placeholder Images for Webmasters - Digital.com",
        "image - Draw number like placeholder.com with golang - Stack Overflow",
        "image - Draw number like placeholder.com with golang - Stack Overflow",
        "jQuery Plugin For Responsive Equal Height Images - packed-img-strip ..."
    ]
}

Request Format

CURL request

curl -X POST http://localhost:5000/search \
    -H "Content-Type: application/json" \
    -d '{
        "image_url":
            "image_url",
        "resized_images":true
        }'

Response Format

{
    "best_guess": "best guess for image",
    "descriptions": ["test description", "..."],
    "links": ["http://test_link.com", "..."],
    "similar_images": ["http://test_image.jpg", "..."],
    "titles": ["test title", "..."],
    "resized_images": ["{
        'rh' : 'resource_host',
        'ru' : 'resource_url',
        'ou' : 'original_url of image',
        'oh' : 'orginal_height of image',
        'ow' : 'original_width of image',
        'ity': 'type of image',
        'tu' : 'thumbnail_url of image', # Generated by Google
        'th' : 'thumbnail_height',
        'tw' : 'thumbnail_width',
        's'  : 'summary',
        '...': '...'
        }", "..."]
}

Response In Detail

"best_guess"

Best guess for the image

"descriptions"

Descriptions from different sources

"links"

Links related to the image

"similar_images"

URLs of similar images (According to Google)

"titles"

List of titles from different sources (Related to that Image)

Resized Images (The same Image in different Sizes and from different Sources)

Request should contain

    "resized_images":true

Usage Example

"resized_images"
    'rh' : 'resource_host',
    'ru' : 'resource_url',
    'ou' : 'original_url of image',
    'oh' : 'orginal_height of image',
    'ow' : 'original_width of image',
    'ity': 'type of image',
    'tu' : 'thumbnail_url of image', # Generated by Google
    'th' : 'thumbnail_height',
    'tw' : 'thumbnail_width',
    's'  : 'summary',

CORS Support

    python src/server.py -c # or --cors

Will enable users to access API from other websites

Google Cloud Vision API

Visit this page for more details about it.

And have a look at the demo on that page

The returned json response can be used to detect:

  • Labels from an image

  • Text from the image and Where it's located (ISO-639-1 languages supported by Google)

  • Web entries

    • Visually similar Images
  • Dominant Colors from the Image

  • Safe Search Level

  • Landmark detection

  • Face detection (emotions etc..)

  • Logo detection

  • Crop Hints for the Image

โš ๏ธ Using "cloud_api":true will only return data from Google's vision API but no more Meta Reverse Image Searching

Request examples

CURL Request

curl -X POST http://localhost:5000/search \
    -H "Content-Type: application/json" \
    -d '{
        "image_url":
            "http://placehold.it/350x150.png",
        "cloud_api":true
        }'

Response Format

Expand to view
{
  "labelAnnotations": [
    {
      "mid": "/m/07s6nbt",
      "description": "text",
      "score": 0.9771333,
      "topicality": 0.9771333
    },

    # more

  ],
  "textAnnotations": [
    {
      "locale": "en",
      "description": "350 x 150\n",
      "boundingPoly": {
        "vertices": [
          {
            "x": 108,
            "y": 56
          },
          # 3 more
        ]
      }
    },

    # more

  ],
  "safeSearchAnnotation": {
    "adult": "VERY_UNLIKELY",
    "spoof": "VERY_UNLIKELY",
    "medical": "UNLIKELY",
    "violence": "VERY_UNLIKELY",
    "racy": "VERY_UNLIKELY"
  },
  "imagePropertiesAnnotation": {
    "dominantColors": {
      "colors": [
        {
          "color": {
            "red": 160,
            "green": 160,
            "blue": 160
          },
          "score": 0.6644681,
          "pixelFraction": 0.021568628
        },

        # more

      ]
    }
  },
  "cropHintsAnnotation": {
    "cropHints": [
      {
        "boundingPoly": {
          "vertices": [
            {
              "x": 104
            },
            {
              "x": 226
            },
            {
              "x": 226,
              "y": 149
            },
            {
              "x": 104,
              "y": 149
            }
          ]
        },
        "confidence": 0.79999995,
        "importanceFraction": 0.79999995
      },

      # more

    ]
  },
  "fullTextAnnotation": {
    "pages": [
      {
        "property": {
          "detectedLanguages": [
            {
              "languageCode": "en",
              "confidence": 1
            }
          ]
        },
        "width": 350,
        "height": 150,
        "blocks": [
          {
            "boundingBox": {
              "vertices": [
                {
                  "x": 108,
                  "y": 56
                },
                # 3 more
              ]
            },
            "paragraphs": [
              {
                "boundingBox": {
                  "vertices": [
                    {
                      "x": 108,
                      "y": 56
                    },
                    # 3 more
                  ]
                },
                "words": [
                  {
                    "property": {
                      "detectedLanguages": [
                        {
                          "languageCode": "en"
                        }
                      ]
                    },
                    "boundingBox": {
                      "vertices": [
                        {
                          "x": 108,
                          "y": 56
                        },
                        # 3 more
                      ]
                    },
                    "symbols": [
                      {
                        "property": {
                          "detectedLanguages": [
                            {
                              "languageCode": "en"
                            }
                          ]
                        },
                        "boundingBox": {
                          "vertices": [
                            {
                              "x": 108,
                              "y": 56
                            },

                            # 3 more

                          ]
                        },
                        "text": "3",
                        "confidence": 0.99
                      },
                      {
                        "property": {
                          "detectedLanguages": [
                            {
                              "languageCode": "en"
                            }
                          ]
                        },
                        "boundingBox": {
                          "vertices": [
                            {
                              "x": 121,
                              "y": 56
                            },

                            # 3 more

                          ]
                        },
                        "text": "5",
                        "confidence": 0.99
                      },
                      {
                        "property": {
                          "detectedLanguages": [
                            {
                              "languageCode": "en"
                            }
                          ],
                          "detectedBreak": {
                            "type": "SPACE"
                          }
                        },
                        "boundingBox": {
                          "vertices": [
                            {
                              "x": 138,
                              "y": 56
                            },

                            # 3 more

                          ]
                        },
                        "text": "0",
                        "confidence": 1
                      }
                    ],
                    "confidence": 0.99
                  },
                  {
                    "property": {
                      "detectedLanguages": [
                        {
                          "languageCode": "en"
                        }
                      ]
                    },
                    "boundingBox": {
                      "vertices": [
                        {
                          "x": 165,
                          "y": 56
                        },

                        # 3 more

                      ]
                    },
                    "symbols": [
                      {
                        "property": {
                          "detectedLanguages": [
                            {
                              "languageCode": "en"
                            }
                          ],
                          "detectedBreak": {
                            "type": "SPACE"
                          }
                        },
                        "boundingBox": {
                          "vertices": [
                            {
                              "x": 165,
                              "y": 56
                            },
                            # 3 more

                          ]
                        },
                        "text": "x",
                        "confidence": 0.99
                      }
                    ],
                    "confidence": 0.99
                  },
                  {
                    "property": {
                      "detectedLanguages": [
                        {
                          "languageCode": "en"
                        }
                      ]
                    },
                    "boundingBox": {
                      "vertices": [
                        {
                          "x": 190,
                          "y": 56
                        },
                        # 3 more
                      ]
                    },
                    "symbols": [
                      {
                        "property": {
                          "detectedLanguages": [
                            {
                              "languageCode": "en"
                            }
                          ]
                        },
                        "boundingBox": {
                          "vertices": [
                            {
                              "x": 190,
                              "y": 56
                            },
                            # 3 more
                          ]
                        },
                        "text": "1",
                        "confidence": 1
                      },
                      {
                        "property": {
                          "detectedLanguages": [
                            {
                              "languageCode": "en"
                            }
                          ]
                        },
                        "boundingBox": {
                          "vertices": [
                            {
                              "x": 208,
                              "y": 56
                            },
                            # 3 more
                          ]
                        },
                        "text": "5",
                        "confidence": 0.99
                      },
                      {
                        "property": {
                          "detectedLanguages": [
                            {
                              "languageCode": "en"
                            }
                          ],
                          "detectedBreak": {
                            "type": "LINE_BREAK"
                          }
                        },
                        "boundingBox": {
                          "vertices": [
                            {
                              "x": 226,
                              "y": 56
                            },
                            # 3 more
                          ]
                        },
                        "text": "0",
                        "confidence": 1
                      }
                    ],
                    "confidence": 0.99
                  }
                ],
                "confidence": 0.99
              }
            ],
            "blockType": "TEXT",
            "confidence": 0.99
          }
        ]
      }
    ],
    "text": "350 x 150\n"
  },
  "webDetection": {
    "webEntities": [
      {
        "entityId": "/m/0jg24",
        "score": 0.7001,
        "description": "Image"
      },

    #more

    ],
    "fullMatchingImages": [
      {
        "url": "http://placehold.it/1920x750?text=G%C3%B6rsel+Yok"
      },

    # more

    ],
    "pagesWithMatchingImages": [
      {
        "url": "https://placeholder.com/",
        "pageTitle": "Placeholder.com - Quick &amp;amp; Simple &lt;b&gt;Placeholder Images&lt;/b&gt;, Text &amp;amp; More",
        "fullMatchingImages": [
          {
            "url": "https://via.placeholder.com/350x150"
          }
        ]
      },

    #more

    ],
    "visuallySimilarImages": [
      {
        "url": "https://via.placeholder.com/350x150"
      },

    #more

    ],
    "bestGuessLabels": [
      {
        "label": "placeholder img",
        "languageCode": "en"
      }
    ]
  }
}

Google Cloud Shell

Open in Cloud Shell

Contributing

Any contributions are always welcome, so if you have made any improvemnts don't hesitate to get in touch - I don't bite :).

Questions

If you have any questions, please don't hesitate to ask in the issues section.

mrisa's People

Contributors

chand1012 avatar d34d10cc avatar daniel1111 avatar dependabot[bot] avatar dhruv4 avatar doggan avatar guoyunhe avatar kevinnovak avatar mirzazulfan avatar mjr128 avatar phanirithvij avatar phanirithvij2000 avatar vivithemage avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

mrisa's Issues

How to get it Working?

I've downloaded the zip file and ran the server and all seems to be okay. But when I paste the localhost url to my browser it gives me a 404. How do I get this going?

Propose Logo

Hi @vivithemage . I'm a graphic designer and an open source enthusiast. I would like to contribute to your project by proposing a logo design. If you have an idea please share with me, it would be better for me. Thanks
mrisa

Best Regard. Mirza Zulfan

localhost/127.0.0.1 useage?

Not so much an issue as a question/request.
I've gotten the software running after some work.
I had to use io.BytesIO() instead of io.StringIO().
I'm using Windows 10 Pro x64 with the Debian Strtetch Linux subsystem installed with curl added on.
Everythings working, but I need to use images in my Apache htdocs directory, or some other local path.
I tried Dropbox, but direct links to files is not possible.
Any help is appreciated. I'm trying to identify over 2000 works of art extracted from a video file.

ConnectionRefusedError

I receive a ConnectionRefusedError when trying to send a POST request to the server running locally on Windows.

What version of Python do you need to run this?

I coudln't tell from the README what version of Python is required for this. I don't see a virtualenv in the download, and when I tried installing via what the README recommended, I got this error

localhost:mrisa-master davea$ pip install -r requirements.txt
ImportError: No module named site

Production App Search

Hello, I like your tool!

I see that you are scraping google results to return to the user. From what I understand any app that is doing this with a steady amount of traffic will get shut down pretty quickly by Google.

I haven't been able to find a google api to do the reverse image search for me - have you looked into that at all? I assume yes and you didn't find anything either :)

Bestguess string is empty after some requests

After around ~140-160 requests Bestguess will be empty for all following requests but if you wait a while (some hours) it works again, i would guess it might be a ratelimit or hidden captcha thing from google.

Google TOS

Does this tool complies with Google's Terms of Service? I'm thinking about using it in a project, looks very nice. Thanks!

Please help tell me what I'm doing wrong :) (no results for Tom Hanks)

Extending the search by using Yandex Image search

i need help.....

I want to use this tool by all means this program.

Traceback (most recent call last):
File "example1.py", line 13, in
r = requests.post(url, headers=headers, data=json.dumps(data))
File "/Users/eunhyulkim/opt/anaconda3/envs/j16134uk/lib/python3.6/site-packages/requests/api.py", line 116, in post
return request('post', url, data=data, json=json, **kwargs)
File "/Users/eunhyulkim/opt/anaconda3/envs/j16134uk/lib/python3.6/site-packages/requests/api.py", line 60, in request
return session.request(method=method, url=url, **kwargs)
File "/Users/eunhyulkim/opt/anaconda3/envs/j16134uk/lib/python3.6/site-packages/requests/sessions.py", line 524, in request
resp = self.send(prep, **send_kwargs)
File "/Users/eunhyulkim/opt/anaconda3/envs/j16134uk/lib/python3.6/site-packages/requests/sessions.py", line 637, in send
r = adapter.send(request, **kwargs)
File "/Users/eunhyulkim/opt/anaconda3/envs/j16134uk/lib/python3.6/site-packages/requests/adapters.py", line 516, in send
raise ConnectionError(e, request=request)
requests.exceptions.ConnectionError: HTTPConnectionPool(host='localhost', port=5000): Max retries exceeded with url: /search (Caused by NewConnectionError('<urllib3.connection.HTTPConnection object at 0x104c1fa90>: Failed to establish a new connection: [Errno 61] Connection refused',))
(j16134uk) EUNHYUKui-MacBook-Pro:python eunhyulkim$

Empty answer

Always returns an empty dictionary on any request.

{'links': [], 'descriptions': [], 'titles': [], 'similar_images': [], 'best_guess': ''}

Unicode in the json file

I discovered some problems in the json files I created from returned data using a modified form of the 'client.py' file.
All json files begin with the letter 'b' and a single quote. Each file ends with a single quote. In between are several unicode characters and escaped characters. Examples are:
'
\
u\00a0
u\00d7
If the iinitial b and single quote are removed, along with the trailing quote, all '\' become ''
and all escaped apostrophes have the back slash removed, then the file is accepted as a json file.
Question is, can these chartacters be removed easily? I'm only vaguely familiar with python string types
and unicode, ASCII, and byte conversions. I could write a script to remove the examples, but is that all that will ever be ever found?

getting this error while deploying this to heroku

I'm getting this error
2020-12-23T06:30:41.158536+00:00 app[web.1]: time.sleep(0.1)
2020-12-23T06:30:41.158597+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.6/site-packages/gunicorn/arbiter.py", line 242, in handle_chld
2020-12-23T06:30:41.161138+00:00 app[web.1]: self.reap_workers()
2020-12-23T06:30:41.161147+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.6/site-packages/gunicorn/arbiter.py", line 525, in reap_workers
2020-12-23T06:30:41.161147+00:00 app[web.1]: raise HaltServer(reason, self.WORKER_BOOT_ERROR)
2020-12-23T06:30:41.161148+00:00 app[web.1]: gunicorn.errors.HaltServer: <HaltServer 'Worker failed to boot.' 3>
2020-12-23T06:30:41.226305+00:00 heroku[web.1]: Process exited with status 1
2020-12-23T06:30:41.274154+00:00 heroku[web.1]: State changed from starting to crashed
2020-12-23T06:30:41.979806+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/" host=image-c2.herokuapp.com request_id=c3d02f51-1371-410e-bdd4-030d3c511a03 fwd="146.196.32.201" dyno= connect= service= status=503 bytes= protocol=https
2020-12-23T06:30:43.227663+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/favicon.ico" host=image-c2.herokuapp.com request_id=3de42211-6971-482c-a463-7263257ff74f fwd="146.196.32.201" dyno= connect= service= status=503 bytes= protocol=https

if you have already deployed somewhere then let me know

Problems with the server.py

I am having problems with the Server.py. Every time I am trying to install the requirements,

ERROR: Could not find a version that satisfies the requirement pycurl==7.19.5
ERROR: No matching distribution found for pycurl==7.19.5

and when I want to send a request, it only returns an Error code <Response [500]>.
The Error I get in the Server

json.decoder.JSONDecodeError: Expecting value: line 1 column 1 (char 0)

I'm running the python example and can see that the server is indeed running and reacting to calls.

I seem to be getting errors related to json:

$ python3 mrisa.py 
Traceback (most recent call last):
  File "/Users/Greg/Projects/Python/GoogleImageSearch/mrisa.py", line 36, in <module>
    print(r.json())
  File "/usr/local/lib/python3.9/site-packages/requests/models.py", line 897, in json
    return complexjson.loads(self.text, **kwargs)
  File "/usr/local/Cellar/[email protected]/3.9.4/Frameworks/Python.framework/Versions/3.9/lib/python3.9/json/__init__.py", line 346, in loads
    return _default_decoder.decode(s)
  File "/usr/local/Cellar/[email protected]/3.9.4/Frameworks/Python.framework/Versions/3.9/lib/python3.9/json/decoder.py", line 337, in decode
    obj, end = self.raw_decode(s, idx=_w(s, 0).end())
  File "/usr/local/Cellar/[email protected]/3.9.4/Frameworks/Python.framework/Versions/3.9/lib/python3.9/json/decoder.py", line 355, in raw_decode
    raise JSONDecodeError("Expecting value", s, err.value) from None
json.decoder.JSONDecodeError: Expecting value: line 1 column 1 (char 0)

I'm using the docker image, although I may be messing that up.

How to troubleshoot?

Getting a 500 Internal Server Error

Hi,

I've got the server successfully running on http://0.0.0.0:5000/ but when I try making a POST request, I get the following error:

<title>500 Internal Server Error</title>

Internal Server Error

The server encountered an internal error and was unable to complete your request. Either the server is overloaded or there is an error in the application.

I just tried the sample request in the docs to try it out.

Any suggestions on how to get it working? Thanks!

Client.py - StringIO is deprecated in Python 3 + a suggestion

The following code is from the server script. You may want to add to the client script or do the replacements listed.
I don't know if io works with older python versions, so for dual compatibility, the 'try' code may be better. Unfortunately, there's no 'PyVer' version reconciliation module to treat compatibility issues.
Seems like a 'no brainer'.
CODE
try:
from StringIO import StringIO
except ImportError:
python3 = True
import io as bytesIOModule
END CODE

Replace :
storage = StrinIO.StrinIO()
with :
storage = io.BytesIO()
and
import io instead of StringIO
additionally
add parentheses for print statement.
The suggestion:
if possible, add the section on Google's return page, entitlesd "Pages that include matching images."
This would create the possibility of searching for larger format images, e.x. 2048x1024.

Fix the Readme

Fix the readme

change all the links which have phanirithvij/mrisa to vivithemage/mrisa

Can you help me?

Respectfully,
Can you help me?

I have a problem right now, but I can't find the cause
I've tried installing Python 2 and 3 several times, but both get errors

My development environment.

pip freeze
Python 2.7
beautifulsoup4==4.6.0
certifi==2018.4.16
chardet==3.0.4
Click==7.0
Flask==0.12.3
Flask-Cors==3.0.6
idna==2.7
itsdangerous==1.1.0
Jinja2==2.10.3
lxml==4.2.4
MarkupSafe==1.1.1
pycurl==7.19.5
requests==2.20.0
six==1.13.0
urllib3==1.24.3
Werkzeug==0.16.0

At run time,

python example.py

(eun) EUNHYUKui-MacBook-Pro:python eunhyulkim$ python example.py
Traceback (most recent call last):
File "example.py", line 12, in
r = requests.post(url, headers=headers, data=json.dumps(data))
File "/Users/eunhyulkim/opt/anaconda3/envs/eun/lib/python2.7/site-packages/requests/api.py", line 116, in post
return request('post', url, data=data, json=json, **kwargs)
File "/Users/eunhyulkim/opt/anaconda3/envs/eun/lib/python2.7/site-packages/requests/api.py", line 60, in request
return session.request(method=method, url=url, **kwargs)
File "/Users/eunhyulkim/opt/anaconda3/envs/eun/lib/python2.7/site-packages/requests/sessions.py", line 524, in request
resp = self.send(prep, **send_kwargs)
File "/Users/eunhyulkim/opt/anaconda3/envs/eun/lib/python2.7/site-packages/requests/sessions.py", line 637, in send
r = adapter.send(request, **kwargs)
File "/Users/eunhyulkim/opt/anaconda3/envs/eun/lib/python2.7/site-packages/requests/adapters.py", line 516, in send
raise ConnectionError(e, request=request)
requests.exceptions.ConnectionError: HTTPConnectionPool(host='localhost', port=5000): Max retries exceeded with url: /search (Caused by NewConnectionError('<urllib3.connection.HTTPConnection object at 0x10d52f3d0>: Failed to establish a new connection: [Errno 61] Connection refused',))


At run time, server.py

(eun) EUNHYUKui-MacBook-Pro:src eunhyulkim$ python server.py

  • Running on http://0.0.0.0:5000/ (Press CTRL+C to quit)
    127.0.0.1 - - [15/Nov/2019 02:27:01] "GET / HTTP/1.1" 404 -
    127.0.0.1 - - [15/Nov/2019 02:27:06] "GET / HTTP/1.1" 404 -
    127.0.0.1 - - [15/Nov/2019 02:27:07] "GET / HTTP/1.1" 404 -
    127.0.0.1 - - [15/Nov/2019 02:27:51] "GET /search HTTP/1.1" 405 -
    127.0.0.1 - - [15/Nov/2019 02:27:51] "GET /favicon.ico HTTP/1.1" 404 -

and

Not Found
The requested URL was not found on the server. If you entered the URL manually please check your spelling and try again.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.