[orx-runway] Add BASNet, PersonSegmentation, U-2-Net presets
This commit is contained in:
committed by
Edwin Jakobs
parent
4a24cb5fea
commit
555ec41530
@@ -7,6 +7,11 @@ class AttnGANRequest(val caption: String)
|
||||
|
||||
class AttnGANResult(val result: String)
|
||||
|
||||
// -- BASNET
|
||||
class BASNETRequest(val image: String)
|
||||
|
||||
class BASNETResult(val image: String)
|
||||
|
||||
// -- BDCN
|
||||
class BdcnRequest(val input_image: String)
|
||||
|
||||
@@ -67,6 +72,17 @@ class DeOldifyResponse(val image: String)
|
||||
class DenseCapRequest(val image: String, @SerializedName("max_detections") val maxDetections: Int = 10)
|
||||
class DenseCapResponse(val bboxes: List<List<Double>>, val classes: List<String>, val scores: List<Double>)
|
||||
|
||||
// -- Person-Segmentation
|
||||
/**
|
||||
* Automatically detects people and extracts them from photos
|
||||
*
|
||||
* @property image
|
||||
* @property threshold [0.0, 1.0]
|
||||
*/
|
||||
class PersonSegmentationRequest(val image: String, val threshold: Double)
|
||||
|
||||
class PersonSegmentationResult(val image: String)
|
||||
|
||||
// -- PoseNet
|
||||
class PoseNetRequest(
|
||||
val image: String,
|
||||
@@ -76,3 +92,7 @@ class PoseNetRequest(
|
||||
)
|
||||
class PoseNetResponse(val poses: List<List<List<Double>>>, val scores: List<Double>)
|
||||
|
||||
// -- U-2-Net
|
||||
class U2NetRequest(val image: String)
|
||||
|
||||
class U2NetResult(val image: String)
|
||||
|
||||
@@ -44,14 +44,13 @@ inline fun <Q, reified R> runwayQuery(target: String, query: Q): R {
|
||||
try {
|
||||
val queryJson = Gson().toJson(query)
|
||||
val connection = URL(target).openConnection() as HttpURLConnection
|
||||
//with(connection) {
|
||||
|
||||
connection.doOutput = true
|
||||
connection.connectTimeout = 1_000
|
||||
connection.readTimeout = 200_000
|
||||
connection.requestMethod = "POST"
|
||||
connection.setRequestProperty("Content-Type", "application/json")
|
||||
connection.setRequestProperty("Accept", "application/json")
|
||||
//}
|
||||
|
||||
val outputStream = connection.outputStream
|
||||
outputStream.write(queryJson.toByteArray())
|
||||
@@ -59,9 +58,10 @@ inline fun <Q, reified R> runwayQuery(target: String, query: Q): R {
|
||||
|
||||
val inputStream = connection.inputStream
|
||||
val responseJson = String(inputStream.readBytes())
|
||||
println(responseJson)
|
||||
|
||||
inputStream.close()
|
||||
connection.disconnect()
|
||||
|
||||
return Gson().fromJson(responseJson, R::class.java)
|
||||
} catch (e: SocketTimeoutException) {
|
||||
error("RunwayML connection timed out '$target'. Check if Runway and model are running.")
|
||||
|
||||
Reference in New Issue
Block a user