« first day (5170 days earlier)   

12:24
hello developers. hope you guys doing well. I need one help. Please help me.
I want to use python pretrained model in my android project written in kotlin.
Tim
Tim
one help in the holiday period is 99eu. January will be cheaper if you prefer to wait
seriously
just for clarity? what is this room for?
First off all: I see no question. Second of all: this is way too little details to be even remotely able to support
Third: Read the room rules (top right :P )
I will give details. full of details.
12:31
I have a pretrained model in (.pt format) that is pytorch.

I wanna do image inpainting that is removing object from image.

implementation 'org.pytorch:pytorch_android:2.1.0'
implementation 'org.pytorch:pytorch_android_torchvision:2.1.0'

I implemeted these dependecy and everthing looks perfect. but issue is when I am getting the tensorOutput and when I am trying to convert that tensorOut to Bitmap then getting a wired image output

here i am adding code that i am trying right now.

private val model: Module = Module.load(assetFilePath(context, assetFileName))
> here i am adding code that i am trying right now.
Please do not expect us to read that much code in a chat...
this is the output i m getting, that is not the correct one. but using same model in python project is working fine and givving correct output
make a question on SO, like really. Chat is useful for general help to go into the right direction but not for so much code in bad formatting and no syntax highlighting. Also best would be to share a minimal project that shows your issue
in short..

1. initializing the model
private val model: Module = Module.load(assetFilePath(context, assetFileName))

2. doing preProcesBitmap:
val (imageTensor, _) = preprocessBitmap(imageBitmap)

val (maskTensor, _) = preprocessBitmap(maskBitmap, isMask = true)

3. passing tensor to the model:
val outputTensor =
model.forward(IValue.from(imageTensor), IValue.from(maskTensor)).toTensor()

4. getting bitmap from tensorOutput
val scores: FloatArray = outputTensor.dataAsFloatArray

val shape = outputTensor.shape()
Python code...

and I used this code to export my model to use in android ...

scripted_module = torch.jit.script(self.model)
optimized_scripted_module = optimize_for_mobile(scripted_module)

# # using optimized lite interpreter model makes inference about 60% faster than the non-optimized lite interpreter model, which is about 6% faster than the non-optimized full jit model
optimized_scripted_module._save_for_lite_interpreter("big_lama_lite.ptl")
@WarrenFaith

is that helpful,
Nope. I never worked with that library at all and you do not read what I wrote. So I am done from my side.
 
1 hour later…
Tim
Tim
13:59
missed out on 99eu there warren
 
2 hours later…
16:06
That was not even my hourly rating 20 years ago...
 
2 hours later…
17:41
@WarrenFaith yea chat îs useful...
@Kaunain this made my day. Thanks Tim

« first day (5170 days earlier)