-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathjLama.bas
More file actions
executable file
·66 lines (59 loc) · 1.69 KB
/
Copy pathjLama.bas
File metadata and controls
executable file
·66 lines (59 loc) · 1.69 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
B4J=true
Group=Default Group
ModulesStructureVersion=1
Type=Class
Version=10
@EndOfDesignText@
Sub Class_Globals
Private engine As JavaObject
Private th As Thread
Private mModelPath As String
End Sub
'Initializes the object. You can add parameters to this method if needed.
Public Sub Initialize(modelPath As String)
th.Initialise("th")
mModelPath = modelPath
End Sub
Public Sub loadModelAsync As ResumableSub
Log("loading lama model")
Dim map1 As Map
map1.Initialize
th.Start(Me,"loadModelUsingMap",Array As Map(map1))
wait for th_Ended(endedOK As Boolean, error As String)
Log(endedOK)
Log(error)
Log("model loaded")
engine = map1.Get("engine")
Return engine
End Sub
Public Sub loadModel
engine.InitializeNewInstance("com.xulihang.LamaInference",Array(mModelPath))
End Sub
Public Sub inpaintAsync(image As cvMat,mask As cvMat) As ResumableSub
Dim map1 As Map
map1.Initialize
map1.Put("image",image)
map1.Put("mask",mask)
Log(map1)
th.Start(Me,"inpaintUsingMap",Array As Map(map1))
wait for th_Ended(endedOK As Boolean, error As String)
Log(endedOK)
Log(error)
Dim out As cvMat = map1.Get("out")
Return out
End Sub
Public Sub inpaint(image As cvMat,mask As cvMat) As cvMat
Dim jo As JavaObject = engine.RunMethod("inpaint",Array(image.JO,mask.JO))
Return cv2.matJO2mat(jo)
End Sub
Private Sub inpaintUsingMap(map1 As Map)
Dim image As cvMat = map1.Get("image")
Dim mask As cvMat = map1.Get("mask")
Dim jo As JavaObject = engine.RunMethod("inpaint",Array(image.JO,mask.JO))
map1.Put("out",cv2.matJO2mat(jo))
End Sub
Private Sub loadModelUsingMap(map1 As Map)
Dim jo As JavaObject
jo.InitializeNewInstance("com.xulihang.LamaInference",Array(mModelPath))
map1.Put("engine",jo)
End Sub