#DeepFakes with Java

1 messages · Page 1 of 1 (latest)

nova totem
#

Hey, I am making a deepfake backend with Spring boot, however, because the big libraries are on python, I need to be able to communicate with the python processes.

Is it possible to call python code inside of Java? From doing research, the best way is through something like ProcessBuilder, which I can start the process, and read the stream.

Is this the optimal way?

spare kayakBOT
#

<@&987246399047479336> please have a look, thanks.

spare kayakBOT
#

While you are waiting for getting help, here are some tips to improve your experience:

Code is much easier to read if posted with syntax highlighting and proper formatting.

If nobody is calling back, that usually means that your question was not well asked and hence nobody feels confident enough answering. Try to use your time to elaborate, provide details, context, more code, examples and maybe some screenshots. With enough info, someone knows the answer for sure.

Don't forget to close your thread using the command </help-thread close:1027500463647621170> when your question has been answered, thanks.

nova totem
#

I am thinking the optimal play is to use spring boot as the main backend, and use some sort of microservice where I can call the python server

nova totem
#

My guess is this architecture view would be more efficient then directly calling python code in java?

lilac jolt
#

Instead of ProcessBuilder check if you can use Jython

#
PythonInterpreter interpreter = new PythonInterpreter();
interpreter.execfile("path-to-.py-file");
interpreter.exec("someValue = yourPythonFunction(param)");
Integer someValue = (Integer) interpreter.eval("someValue").__tojava__(Integer.class);
#

In this example, I call my custom "yourPythonFunction" method that I declared in my custom Python file, within python I set the value to someValue then I grab the value for someValue as an Integer

#

That'll cut out your need for a python server if your servers sole purpose is to run a python function and output the result

#

But that's up to you - if you do have a microservice though having a separate python server would be better

nova totem
#

hmm that's much better then ProcessBuilder

#

I think in terms of the scope of the project, using Jython might actually be a better option

#

it seems flexible

severe sky
#

okay ugh

#
  1. libpython-clj is probably the best jvm python binding. It has a java api
#
  1. ....why are you making a deepfake thing?
nova totem
#

it will be a select few people who will get to use it, and it will be hopefully ethically okay

#

my intentions are for it to just be something funny where you can put someone's face over a meme or something

#

and hmm libpython seems interesting

severe sky
#

yeah - the use case for libpython is using python ecosystem ML stuff

#

its hard to get the env right - like always with python - but it is a really good option once that is done

nova totem
severe sky
#
  1. jython is unmaintained as hell
#
  1. jython won't be able to use python ml stuff
#

that all works with python's C interface

#
  1. The library is written in Clojure but you can just use its java API
#

and also I would drop the react/angular and just server side render

#

make your life easier

nova totem
#

probably just use spring for ssr then?

#

Using something like vaadin or thymeleaf

severe sky
#

are you just allowed to use anything at all?

nova totem
#

yeah anything

#

I could use python only

severe sky
#

then why not just use python

#

yeah

#

way simpler

nova totem
#

yeah but I wanted to use spring lol

#

it probably is a lot simpler

#

would cut the hassle of running python through java

severe sky
#

if you want to use clojure im sure thats another fun one

#

or elixir - if your model is on huggingfaces then i know elixir ml can run it

nova totem
#

Oh really?

nova totem
#

Yeah just saw this

#

hmm this might be interesting to look into

nova totem
#

appreciate it btw