vivithemage/mrisa

localhost/127.0.0.1 useage?

Closed this issue · 4 comments

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.

Thanks for getting in touch.

The software currently only works with publicly available images.
However, you could create a github repository with the images and reference them that way. For example:

https://raw.githubusercontent.com/jimlynnjulian/imagerepo/master/image1.png
https://raw.githubusercontent.com/jimlynnjulian/imagerepo/master/image2.png
https://raw.githubusercontent.com/jimlynnjulian/imagerepo/master/image3.png

Could you let me know the changes you made to get it to work on your machine and I'll take a closer look.

Thanks again

Thank you for your response. I used the Github repository as an image repository successfully. Thanks for the idea.
I was prepared to use an image cloud but Github seems likely to be better.
I have had a problem with the returned json code, though.
I wanted to 'prettify' the code to make reading easier, but every formatting code I use returns errors or problems. I tried a json validater website, https://jsonlint.com/, and the code fails with every correctioin I make.
The problem, I found, is the json file contains python unicode, e.x.
b'{good morning : it's good to be up.}'
There is a prepended 'b' and the rest is enclosed in single quotes.
This is not a true json file.

NOTE: I found the problem and discuss the solution and issue in the last post.

json_files.zip

Thank you.

Hello,
Some clarification:
The json returned by client.py is not the same as that returned in the curl request.
I'm using notepad++, with the json viewer extension, and the former cannot be parsed while the latter can.

I found the modified file:client.py
I'm using Python 3.5 and StringIO is deprecated. BytesIO is the suggested replacement.

CODE:
import pycurl
import json
import io

#data = json.dumps({"image_url": "http://upload.wikimedia.org/wikipedia/commons/2/29/Voyager_spacecraft.jpg"})
#data = json.dumps({"image_url": "http://localhost/search/Voyager_spacecraft.jpg"})
#data = json.dumps({"image_url": "http://127.0.0.1/search/Voyager_spacecraft.jpg"})
data = json.dumps({"image_url": "https://raw.githubusercontent.com/jimlynnjulian/classical_gas/master/out0007.jpg"})

url = 'http://localhost/search'
##########################
storage = io.BytesIO()
##########################
c = pycurl.Curl()
c.setopt(c.URL, str(url))
c.setopt(c.PORT, 5000)
c.setopt(c.HTTPHEADER, ['Content-Type: application/json'])
c.setopt(pycurl.POST, 1)
c.setopt(pycurl.POSTFIELDS, data)
c.setopt(c.WRITEFUNCTION, storage.write)
c.perform()
c.close()

returned_json = storage.getvalue()
print (returned_json)
END CODE

This was a suggestion only, but a problem has emerged and will be opened as another, separate, issue.