Django framework with machine learning

51 views
Skip to first unread message

Lansana Sangare

unread,
Apr 27, 2020, 2:31:37 PM4/27/20
to Django users
Good evening,

I am a new developer in Django but I have the basic knowledge.

I wanted to know if someone has experience with django and machine learning.

I have a script in python that shows a video with keypoints and 3D reconstruction. 

Is it possible with django framework to execute and display this script on a web interface.

 Thank you in advance !

yashwanth .k

unread,
Apr 29, 2020, 2:22:10 AM4/29/20
to django...@googlegroups.com
Can you please post some shots of output.

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/1ea065ee-79a2-48ca-9b9e-c03a761ee741%40googlegroups.com.

Lansana Sangare

unread,
Apr 30, 2020, 7:21:39 PM4/30/20
to Django users


Good evening here is the output on the developpement server and the code in django, for smaller scripts I get the output, but for larger ones I get strange output or sometimes not. In the attachment I have the large file run.py that I run in my django app. I ask for help if someone already has experience with it.

thanks in advance


code_django.png

output.png



Am Mittwoch, 29. April 2020 08:22:10 UTC+2 schrieb yashwanth .k:
Can you please post some shots of output.

On Tue, Apr 28, 2020 at 12:01 AM Lansana Sangare <Lansa...@gmail.com> wrote:
Good evening,

I am a new developer in Django but I have the basic knowledge.

I wanted to know if someone has experience with django and machine learning.

I have a script in python that shows a video with keypoints and 3D reconstruction. 

Is it possible with django framework to execute and display this script on a web interface.

 Thank you in advance !

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django...@googlegroups.com.
run.py

Kasper Laudrup

unread,
May 1, 2020, 4:42:26 AM5/1/20
to django...@googlegroups.com
Hi Lansana,

On 01/05/2020 01.21, Lansana Sangare wrote:
>
> Good evening here is the output on the developpement server and the code
> in django, for smaller scripts I get the output, but for larger ones I
> get strange output or sometimes not. In the attachment I have the large
> file run.py that I run in my django app. I ask for help if someone
> already has experience with it.
>

Some thoughts.

You are collecting all the output from stdout into the out object
returned from the the subprocess run() function.

That means the run function is buffering stdout before returning from
the call. I haven't been able to find a limit on the buffer size (which
could explain why it never returns), but even if there is no limit, you
most likely want to return the output in chunks to improve user
experience and limit memory usage.

Try to look at popen and use that instead:

https://docs.python.org/3/library/subprocess.html

The strange output is caused by combining the output from stdout and
stderr. You almost certainly don't want to return output from stderr to
the user, but consider that an error/exception and handle that
internally. The popen object should help you with that. If the script
you are calling is well written, it will return a non-successful return
code (ie. not 0) on errors which should cause an exception you can handle.

Finally, you are passing user input directly from the user (the "param"
POST value) to the script. As long as you don't execute it through the
shell, it is probably not much of a security issue, but be careful and
assume that the inp variable could contain anything and is not under
your control.

Hope that can help you in the right direction. I don't have any complete
solution, but that's what I would look into.

Kind regards,

Kasper Laudrup
Reply all
Reply to author
Forward
0 new messages