Python script in Android Studio

Viewed 83

Is there a way to make Android studio/Java execute a python program?

import deepdream
from deepdream import model, load_image, recursive_optimize
import numpy as np
import PIL.Image


layer_tensor = model.layer_tensors[11]

file_name = "Image.jpg"

img = load_image(filename='{}'.format(file_name))
img_result = recursive_optimize(layer_tensor=layer_tensor, image=img,
                
                num_iterations=20, step_size=1.0, rescale_factor=0.5,
                
                num_repeats=4, blend=0.2)

img_result = np.clip(img_result, 0.0, 255.0)
img_result = img_result.astype(np.uint8)
result = PIL.Image.fromarray(img_result, mode='RGB')
result.save("output.jpg")

This is the script that I want to execute but it depends on a couple of other files as well.

It essentially has to execute this when told to do so by the user.

0 Answers
Related