[orx-runway] Comment out demos that do not compile

This commit is contained in:
Edwin Jakobs
2024-08-14 12:07:21 +02:00
parent 93ace56443
commit ff044523de
13 changed files with 563 additions and 563 deletions

View File

@@ -1,46 +1,46 @@
import org.openrndr.application //import org.openrndr.application
import org.openrndr.color.ColorRGBa //import org.openrndr.color.ColorRGBa
import org.openrndr.draw.ColorBuffer //import org.openrndr.draw.ColorBuffer
import org.openrndr.draw.isolatedWithTarget //import org.openrndr.draw.isolatedWithTarget
import org.openrndr.draw.loadFont //import org.openrndr.draw.loadFont
import org.openrndr.draw.renderTarget //import org.openrndr.draw.renderTarget
import org.openrndr.extra.runway.* //import org.openrndr.extra.runway.*
import org.openrndr.math.smoothstep //import org.openrndr.math.smoothstep
//
/** ///**
* This demonstrates an image reinterpretation effect. // * This demonstrates an image reinterpretation effect.
* This example requires a `runway/BigBiGAN` model to be active in Runway. // * This example requires a `runway/BigBiGAN` model to be active in Runway.
*/ // */
//
fun main() = application { //fun main() = application {
configure { // configure {
width = 512 // width = 512
height = 256 // height = 256
} // }
//
program { // program {
val rt = renderTarget(256, 256) { // val rt = renderTarget(256, 256) {
colorBuffer() // colorBuffer()
} // }
val font = loadFont("demo-data/fonts/IBMPlexMono-Regular.ttf", 256.0) // val font = loadFont("demo-data/fonts/IBMPlexMono-Regular.ttf", 256.0)
val alphabet = "ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789" // val alphabet = "ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789"
extend { // extend {
drawer.isolatedWithTarget(rt) { // drawer.isolatedWithTarget(rt) {
drawer.clear(ColorRGBa.BLACK) // drawer.clear(ColorRGBa.BLACK)
drawer.ortho(rt) // drawer.ortho(rt)
val it = seconds.toInt() // val it = seconds.toInt()
val t = seconds - it // val t = seconds - it
drawer.fill = ColorRGBa.PINK.shade(smoothstep(0.0, 0.2, t) * smoothstep(1.0, 0.8, t)) // drawer.fill = ColorRGBa.PINK.shade(smoothstep(0.0, 0.2, t) * smoothstep(1.0, 0.8, t))
drawer.fontMap = font // drawer.fontMap = font
drawer.text("" + alphabet[seconds.toInt()], 64.0, 128.0 + 64) // drawer.text("" + alphabet[seconds.toInt()], 64.0, 128.0 + 64)
} // }
val result: BigBiGANResult = // val result: BigBiGANResult =
runwayQuery("http://localhost:8000/query", BigBiGANQuery(rt.colorBuffer(0).toData())) // runwayQuery("http://localhost:8000/query", BigBiGANQuery(rt.colorBuffer(0).toData()))
//
val image = ColorBuffer.fromData(result.outputImage) // val image = ColorBuffer.fromData(result.outputImage)
drawer.image(rt.colorBuffer(0)) // drawer.image(rt.colorBuffer(0))
drawer.image(image, 256.0, 0.0) // drawer.image(image, 256.0, 0.0)
image.destroy() // image.destroy()
} // }
} // }
} //}

View File

@@ -1,49 +1,49 @@
import org.openrndr.application //import org.openrndr.application
import org.openrndr.color.ColorRGBa //import org.openrndr.color.ColorRGBa
import org.openrndr.draw.* //import org.openrndr.draw.*
import org.openrndr.extra.runway.* //import org.openrndr.extra.runway.*
//
/** ///**
* This demonstrates an image feedback effect. It starts from a single image. // * This demonstrates an image feedback effect. It starts from a single image.
* The BigBiGAN generates a new image from the input, this program feeds the // * The BigBiGAN generates a new image from the input, this program feeds the
* generated image back into the model (with an additional distortion). // * generated image back into the model (with an additional distortion).
* This example requires a `runway/BigBiGAN` model to be active in Runway. // * This example requires a `runway/BigBiGAN` model to be active in Runway.
*/ // */
fun main() = application { //fun main() = application {
configure { // configure {
width = 512 // width = 512
height = 512 // height = 512
} // }
//
program { // program {
val rt = renderTarget(256, 256) { // val rt = renderTarget(256, 256) {
colorBuffer() // colorBuffer()
} // }
val startImage = loadImage("demo-data/images/portrait.jpg") // val startImage = loadImage("demo-data/images/portrait.jpg")
//
drawer.isolatedWithTarget(rt) { // drawer.isolatedWithTarget(rt) {
drawer.ortho(rt) // drawer.ortho(rt)
drawer.clear(ColorRGBa.BLACK) // drawer.clear(ColorRGBa.BLACK)
drawer.image(startImage, (rt.width - startImage.width) / 2.0, (rt.height - startImage.height) / 2.0) // drawer.image(startImage, (rt.width - startImage.width) / 2.0, (rt.height - startImage.height) / 2.0)
} // }
//
extend { // extend {
val result: BigBiGANResult = // val result: BigBiGANResult =
runwayQuery("http://localhost:8000/query", BigBiGANQuery(rt.colorBuffer(0).toData())) // runwayQuery("http://localhost:8000/query", BigBiGANQuery(rt.colorBuffer(0).toData()))
//
val image = ColorBuffer.fromData(result.outputImage) // val image = ColorBuffer.fromData(result.outputImage)
drawer.image(image, 0.0, 0.0, 512.0, 512.0) // drawer.image(image, 0.0, 0.0, 512.0, 512.0)
//
drawer.isolatedWithTarget(rt) { // drawer.isolatedWithTarget(rt) {
drawer.ortho(rt) // drawer.ortho(rt)
drawer.translate(image.width / 2.0, image.height / 2.0) // drawer.translate(image.width / 2.0, image.height / 2.0)
drawer.rotate(10.0) // drawer.rotate(10.0)
drawer.translate(-image.width / 2.0, -image.height / 2.0) // drawer.translate(-image.width / 2.0, -image.height / 2.0)
drawer.drawStyle.colorMatrix = tint(ColorRGBa.WHITE.opacify(0.5)) // drawer.drawStyle.colorMatrix = tint(ColorRGBa.WHITE.opacify(0.5))
drawer.image(image) // drawer.image(image)
} // }
image.destroy() // image.destroy()
} // }
} // }
} //}
//

View File

@@ -1,36 +1,36 @@
import org.openrndr.application //import org.openrndr.application
import org.openrndr.color.ColorRGBa //import org.openrndr.color.ColorRGBa
import org.openrndr.draw.ColorBuffer //import org.openrndr.draw.ColorBuffer
import org.openrndr.draw.loadFont //import org.openrndr.draw.loadFont
import org.openrndr.extra.runway.AttnGANRequest //import org.openrndr.extra.runway.AttnGANRequest
import org.openrndr.extra.runway.AttnGANResult //import org.openrndr.extra.runway.AttnGANResult
import org.openrndr.extra.runway.runwayQuery //import org.openrndr.extra.runway.runwayQuery
import java.io.File //import java.io.File
//
/** ///**
* This demonstrates a text to image network. It generates images from single words. // * This demonstrates a text to image network. It generates images from single words.
* This example requires a `runway/AttnGAN` model to be active in Runway. // * This example requires a `runway/AttnGAN` model to be active in Runway.
*/ // */
//
fun main() = application { //fun main() = application {
configure { // configure {
width = 768 // width = 768
height = 576 // height = 576
} // }
//
program { // program {
val runwayHost = "http://localhost:8000/query" // val runwayHost = "http://localhost:8000/query"
val words = File("demo-data/words/words.txt").readText().split("\n") // val words = File("demo-data/words/words.txt").readText().split("\n")
val font = loadFont("demo-data/fonts/IBMPlexMono-Regular.ttf", 72.0) // val font = loadFont("demo-data/fonts/IBMPlexMono-Regular.ttf", 72.0)
extend { // extend {
val text = words.random() // val text = words.random()
val result: AttnGANResult = runwayQuery(runwayHost, AttnGANRequest(text)) // val result: AttnGANResult = runwayQuery(runwayHost, AttnGANRequest(text))
val image = ColorBuffer.fromUrl(result.result) // val image = ColorBuffer.fromUrl(result.result)
drawer.fontMap = font // drawer.fontMap = font
drawer.image(image, (width - image.width) / 2.0, (height - image.height) / 2.0) // drawer.image(image, (width - image.width) / 2.0, (height - image.height) / 2.0)
drawer.fill = ColorRGBa.PINK // drawer.fill = ColorRGBa.PINK
drawer.text(text, 40.0, height / 2.0) // drawer.text(text, 40.0, height / 2.0)
image.destroy() // image.destroy()
} // }
} // }
} //}

View File

@@ -1,39 +1,39 @@
import org.openrndr.application //import org.openrndr.application
import org.openrndr.color.ColorRGBa //import org.openrndr.color.ColorRGBa
import org.openrndr.draw.ColorBuffer //import org.openrndr.draw.ColorBuffer
import org.openrndr.draw.loadFont //import org.openrndr.draw.loadFont
import org.openrndr.extra.runway.AttnGANRequest //import org.openrndr.extra.runway.AttnGANRequest
import org.openrndr.extra.runway.AttnGANResult //import org.openrndr.extra.runway.AttnGANResult
import org.openrndr.extra.runway.runwayQuery //import org.openrndr.extra.runway.runwayQuery
import java.io.File //import java.io.File
//
/** ///**
* This demonstrates a text to image network. It generates images from simple sentences. // * This demonstrates a text to image network. It generates images from simple sentences.
* This example requires a `runway/AttnGAN` model to be active in Runway. // * This example requires a `runway/AttnGAN` model to be active in Runway.
*/ // */
//
fun main() = application { //fun main() = application {
configure { // configure {
width = 768 // width = 768
height = 576 // height = 576
} // }
//
program { // program {
val runwayHost = "http://localhost:8000/query" // val runwayHost = "http://localhost:8000/query"
val nouns = File("demo-data/words/nouns.txt").readText().split("\n") // val nouns = File("demo-data/words/nouns.txt").readText().split("\n")
val prepositions = File("demo-data/words/prepositions.txt").readText().split("\n") // val prepositions = File("demo-data/words/prepositions.txt").readText().split("\n")
val adjectives = File("demo-data/words/adjectives.txt").readText().split("\n") // val adjectives = File("demo-data/words/adjectives.txt").readText().split("\n")
val font = loadFont("demo-data/fonts/IBMPlexMono-Regular.ttf", 36.0) // val font = loadFont("demo-data/fonts/IBMPlexMono-Regular.ttf", 36.0)
//
extend { // extend {
val text = "a ${adjectives.random()} ${nouns.random()} ${prepositions.random()} a ${adjectives.random()} ${nouns.random()}" // val text = "a ${adjectives.random()} ${nouns.random()} ${prepositions.random()} a ${adjectives.random()} ${nouns.random()}"
val result: AttnGANResult = runwayQuery(runwayHost, AttnGANRequest(text)) // val result: AttnGANResult = runwayQuery(runwayHost, AttnGANRequest(text))
val image = ColorBuffer.fromUrl(result.result) // val image = ColorBuffer.fromUrl(result.result)
drawer.fontMap = font // drawer.fontMap = font
drawer.image(image, (width - image.width) / 2.0, (height - image.height) / 2.0) // drawer.image(image, (width - image.width) / 2.0, (height - image.height) / 2.0)
drawer.fill = ColorRGBa.PINK // drawer.fill = ColorRGBa.PINK
drawer.text(text, 40.0, height - 40.0) // drawer.text(text, 40.0, height - 40.0)
image.destroy() // image.destroy()
} // }
} // }
} //}

View File

@@ -1,40 +1,40 @@
import org.openrndr.application //import org.openrndr.application
import org.openrndr.color.ColorRGBa //import org.openrndr.color.ColorRGBa
import org.openrndr.draw.ColorBuffer //import org.openrndr.draw.ColorBuffer
import org.openrndr.draw.isolatedWithTarget //import org.openrndr.draw.isolatedWithTarget
import org.openrndr.draw.loadImage //import org.openrndr.draw.loadImage
import org.openrndr.draw.renderTarget //import org.openrndr.draw.renderTarget
import org.openrndr.extra.runway.* //import org.openrndr.extra.runway.*
//
/** ///**
* This demonstrates the body estimation model of DensePose // * This demonstrates the body estimation model of DensePose
* This example requires a `runway/DensePose` model active in Runway. // * This example requires a `runway/DensePose` model active in Runway.
*/ // */
fun main() = application { //fun main() = application {
configure { // configure {
width = 512 // width = 512
height = 512 // height = 512
} // }
//
program { // program {
val rt = renderTarget(512, 512) { // val rt = renderTarget(512, 512) {
colorBuffer() // colorBuffer()
} // }
val startImage = loadImage("demo-data/images/peopleCity01.jpg") // val startImage = loadImage("demo-data/images/peopleCity01.jpg")
//
drawer.isolatedWithTarget(rt) { // drawer.isolatedWithTarget(rt) {
drawer.ortho(rt) // drawer.ortho(rt)
drawer.clear(ColorRGBa.BLACK) // drawer.clear(ColorRGBa.BLACK)
drawer.image(startImage, (rt.width - startImage.width) / 2.0, (rt.height - startImage.height) / 2.0) // drawer.image(startImage, (rt.width - startImage.width) / 2.0, (rt.height - startImage.height) / 2.0)
} // }
//
extend { // extend {
val result: DensePoseResult = // val result: DensePoseResult =
runwayQuery("http://localhost:8000/query", DensePoseQuery(rt.colorBuffer(0).toData())) // runwayQuery("http://localhost:8000/query", DensePoseQuery(rt.colorBuffer(0).toData()))
val image = ColorBuffer.fromData(result.output) // val image = ColorBuffer.fromData(result.output)
//
drawer.image(image, 0.0, 0.0, 512.0, 512.0) // drawer.image(image, 0.0, 0.0, 512.0, 512.0)
image.destroy() // image.destroy()
} // }
} // }
} //}

View File

@@ -1,41 +1,41 @@
import org.openrndr.application //import org.openrndr.application
import org.openrndr.draw.ColorBuffer //import org.openrndr.draw.ColorBuffer
import org.openrndr.draw.colorBuffer //import org.openrndr.draw.colorBuffer
import org.openrndr.extra.fx.transform.FlipVertically //import org.openrndr.extra.fx.transform.FlipVertically
import org.openrndr.extra.runway.DeOldifyRequest //import org.openrndr.extra.runway.DeOldifyRequest
import org.openrndr.extra.runway.DeOldifyResponse //import org.openrndr.extra.runway.DeOldifyResponse
import org.openrndr.extra.runway.runwayQuery //import org.openrndr.extra.runway.runwayQuery
import org.openrndr.ffmpeg.VideoPlayerFFMPEG //import org.openrndr.ffmpeg.VideoPlayerFFMPEG
//
/** ///**
* This demonstrates the Deoldify model, which colors grayscale images // * This demonstrates the Deoldify model, which colors grayscale images
* This example requires a `reiinakano/DeOldify` model active in Runway. // * This example requires a `reiinakano/DeOldify` model active in Runway.
*/ // */
//
fun main() = application { //fun main() = application {
configure { // configure {
width = 1280 // width = 1280
height = 360 // height = 360
} // }
//
program { // program {
val image = colorBuffer(640, 360) // val image = colorBuffer(640, 360)
val camera = VideoPlayerFFMPEG.fromDevice(imageWidth = 640, imageHeight = 360) // val camera = VideoPlayerFFMPEG.fromDevice(imageWidth = 640, imageHeight = 360)
camera.play() // camera.play()
val flip = FlipVertically() // val flip = FlipVertically()
//
camera.newFrame.listen { // camera.newFrame.listen {
flip.apply(it.frame, image) // flip.apply(it.frame, image)
} // }
//
extend { // extend {
camera.draw(drawer) // camera.draw(drawer)
val response: DeOldifyResponse = // val response: DeOldifyResponse =
runwayQuery("http://localhost:8000/query", DeOldifyRequest(image.toDataUrl())) // runwayQuery("http://localhost:8000/query", DeOldifyRequest(image.toDataUrl()))
//
val image = ColorBuffer.fromUrl(response.image) // val image = ColorBuffer.fromUrl(response.image)
drawer.image(image, 640.0, 0.0) // drawer.image(image, 640.0, 0.0)
image.destroy() // image.destroy()
} // }
} // }
} //}

View File

@@ -1,50 +1,50 @@
import org.openrndr.application //import org.openrndr.application
import org.openrndr.draw.ColorBuffer //import org.openrndr.draw.ColorBuffer
import org.openrndr.draw.colorBuffer //import org.openrndr.draw.colorBuffer
import org.openrndr.extra.fx.transform.FlipVertically //import org.openrndr.extra.fx.transform.FlipVertically
import org.openrndr.extra.runway.DeOldifyRequest //import org.openrndr.extra.runway.DeOldifyRequest
import org.openrndr.extra.runway.DeOldifyResponse //import org.openrndr.extra.runway.DeOldifyResponse
import org.openrndr.extra.runway.runwayQuery //import org.openrndr.extra.runway.runwayQuery
import org.openrndr.ffmpeg.ScreenRecorder //import org.openrndr.ffmpeg.ScreenRecorder
import org.openrndr.ffmpeg.VideoPlayerConfiguration //import org.openrndr.ffmpeg.VideoPlayerConfiguration
import org.openrndr.ffmpeg.VideoPlayerFFMPEG //import org.openrndr.ffmpeg.VideoPlayerFFMPEG
//
/** ///**
* This demonstrates the Deoldify model, which colors grayscale images // * This demonstrates the Deoldify model, which colors grayscale images
* This example requires a `reiinakano/DeOldify` model active in Runway. // * This example requires a `reiinakano/DeOldify` model active in Runway.
*/ // */
//
fun main() = application { //fun main() = application {
configure { // configure {
width = 1280 // width = 1280
height = 480 // height = 480
} // }
//
program { // program {
val image = colorBuffer(640, 480) // val image = colorBuffer(640, 480)
val vc = VideoPlayerConfiguration().apply { // val vc = VideoPlayerConfiguration().apply {
allowFrameSkipping = false // allowFrameSkipping = false
} // }
// -- you will have to supply your own video here // // -- you will have to supply your own video here
val video = VideoPlayerFFMPEG.fromFile("data/videos/night_of_the_living_dead_512kb.mp4", configuration = vc) // val video = VideoPlayerFFMPEG.fromFile("data/videos/night_of_the_living_dead_512kb.mp4", configuration = vc)
video.play() // video.play()
val flip = FlipVertically() // val flip = FlipVertically()
//
video.newFrame.listen { // video.newFrame.listen {
flip.apply(it.frame, image) // flip.apply(it.frame, image)
} // }
extend(ScreenRecorder()) { // extend(ScreenRecorder()) {
frameRate = 30 // frameRate = 30
} // }
extend { // extend {
video.draw(drawer, 0.0, 0.0, 640.0, 480.0) // video.draw(drawer, 0.0, 0.0, 640.0, 480.0)
val response: DeOldifyResponse = // val response: DeOldifyResponse =
runwayQuery("http://localhost:8000/query", DeOldifyRequest(image.toDataUrl())) // runwayQuery("http://localhost:8000/query", DeOldifyRequest(image.toDataUrl()))
//
val image = ColorBuffer.fromUrl(response.image) // val image = ColorBuffer.fromUrl(response.image)
//
drawer.image(image, 640.0, 0.0) // drawer.image(image, 640.0, 0.0)
image.destroy() // image.destroy()
} // }
} // }
} //}

View File

@@ -1,53 +1,53 @@
import org.openrndr.application //import org.openrndr.application
import org.openrndr.color.ColorRGBa //import org.openrndr.color.ColorRGBa
import org.openrndr.draw.ColorBuffer //import org.openrndr.draw.ColorBuffer
import org.openrndr.draw.loadFont //import org.openrndr.draw.loadFont
import org.openrndr.extra.runway.* //import org.openrndr.extra.runway.*
import org.openrndr.ffmpeg.ScreenRecorder //import org.openrndr.ffmpeg.ScreenRecorder
import java.io.File //import java.io.File
//
/** ///**
* This demonstrates a feedback loop // * This demonstrates a feedback loop
* This example requires: // * This example requires:
* a `runway/im2txt` model active in Runway on port 8000 // * a `runway/im2txt` model active in Runway on port 8000
* a `runway/AttnGAN` model active in Runway on port 8001 // * a `runway/AttnGAN` model active in Runway on port 8001
*/ // */
//
fun main() = application { //fun main() = application {
configure { // configure {
width = 768 // width = 768
height = 576 // height = 576
} // }
//
program { // program {
//
val attnHost = "http://localhost:8001/query" // val attnHost = "http://localhost:8001/query"
val im2txtHost = "http://localhost:8000/query" // val im2txtHost = "http://localhost:8000/query"
//
val nouns = File("demo-data/words/nouns.txt").readText().split("\n") // val nouns = File("demo-data/words/nouns.txt").readText().split("\n")
val prepositions = File("demo-data/words/prepositions.txt").readText().split("\n") // val prepositions = File("demo-data/words/prepositions.txt").readText().split("\n")
val adjectives = File("demo-data/words/adjectives.txt").readText().split("\n") // val adjectives = File("demo-data/words/adjectives.txt").readText().split("\n")
//
val font = loadFont("demo-data/fonts/IBMPlexMono-Regular.ttf", 36.0) // val font = loadFont("demo-data/fonts/IBMPlexMono-Regular.ttf", 36.0)
//
var text = "a ${adjectives.random()} ${nouns.random()} ${prepositions.random()} a ${adjectives.random()} ${nouns.random()}" // var text = "a ${adjectives.random()} ${nouns.random()} ${prepositions.random()} a ${adjectives.random()} ${nouns.random()}"
//
extend(ScreenRecorder()) { // extend(ScreenRecorder()) {
frameRate = 1 // frameRate = 1
} // }
//
extend { // extend {
val result: AttnGANResult = runwayQuery(attnHost, AttnGANRequest(text)) // val result: AttnGANResult = runwayQuery(attnHost, AttnGANRequest(text))
val image = ColorBuffer.fromUrl(result.result) // val image = ColorBuffer.fromUrl(result.result)
drawer.fontMap = font // drawer.fontMap = font
drawer.image(image, (width - image.width)/2.0, (height - image.height)/2.0) // drawer.image(image, (width - image.width)/2.0, (height - image.height)/2.0)
//
val result2:Im2txtResult = runwayQuery(im2txtHost, Im2txtRequest(image.toDataUrl())) // val result2:Im2txtResult = runwayQuery(im2txtHost, Im2txtRequest(image.toDataUrl()))
text = result2.caption // text = result2.caption
//
drawer.fill = ColorRGBa.PINK // drawer.fill = ColorRGBa.PINK
drawer.text(text, 40.0, height - 40.0) // drawer.text(text, 40.0, height - 40.0)
image.destroy() // image.destroy()
} // }
} // }
} //}

View File

@@ -1,66 +1,66 @@
import org.openrndr.application //import org.openrndr.application
import org.openrndr.color.ColorRGBa //import org.openrndr.color.ColorRGBa
import org.openrndr.draw.Writer //import org.openrndr.draw.Writer
import org.openrndr.draw.colorBuffer //import org.openrndr.draw.colorBuffer
import org.openrndr.draw.loadFont //import org.openrndr.draw.loadFont
import org.openrndr.extra.fx.transform.FlipVertically //import org.openrndr.extra.fx.transform.FlipVertically
import org.openrndr.extra.runway.DenseCapRequest //import org.openrndr.extra.runway.DenseCapRequest
import org.openrndr.extra.runway.DenseCapResponse //import org.openrndr.extra.runway.DenseCapResponse
import org.openrndr.extra.runway.runwayQuery //import org.openrndr.extra.runway.runwayQuery
import org.openrndr.ffmpeg.ScreenRecorder //import org.openrndr.ffmpeg.ScreenRecorder
import org.openrndr.ffmpeg.VideoPlayerFFMPEG //import org.openrndr.ffmpeg.VideoPlayerFFMPEG
import org.openrndr.shape.Rectangle //import org.openrndr.shape.Rectangle
//
//
/** ///**
* This demonstrates an object to text network. It generates caption texts from objects detected in // * This demonstrates an object to text network. It generates caption texts from objects detected in
* the camera image // * the camera image
* This example requires a `runway/DenseCap` model to be active in Runway. // * This example requires a `runway/DenseCap` model to be active in Runway.
*/ // */
//
fun main() = application { //fun main() = application {
configure { // configure {
width = 768 // width = 768
height = 576 // height = 576
} // }
//
program { // program {
val image = colorBuffer(640, 360) // val image = colorBuffer(640, 360)
val camera = VideoPlayerFFMPEG.fromDevice(imageWidth = 640, imageHeight = 360) // val camera = VideoPlayerFFMPEG.fromDevice(imageWidth = 640, imageHeight = 360)
camera.play() // camera.play()
val flip = FlipVertically() // val flip = FlipVertically()
//
val font = loadFont("demo-data/fonts/IBMPlexMono-Regular.ttf", 24.0) // val font = loadFont("demo-data/fonts/IBMPlexMono-Regular.ttf", 24.0)
camera.newFrame.listen { // camera.newFrame.listen {
flip.apply(it.frame, image) // flip.apply(it.frame, image)
} // }
extend(ScreenRecorder()) { // extend(ScreenRecorder()) {
frameRate = 1 // frameRate = 1
} // }
extend { // extend {
camera.draw(drawer) // camera.draw(drawer)
drawer.fontMap = font // drawer.fontMap = font
val response: DenseCapResponse = // val response: DenseCapResponse =
runwayQuery("http://localhost:8000/query", DenseCapRequest(image.toDataUrl(), maxDetections = 1)) // runwayQuery("http://localhost:8000/query", DenseCapRequest(image.toDataUrl(), maxDetections = 1))
//
drawer.fontMap = font // drawer.fontMap = font
drawer.image(image) // drawer.image(image)
//
for (i in response.bboxes.indices) { // for (i in response.bboxes.indices) {
val width = (response.bboxes[i][2] - response.bboxes[i][0]) * image.width // val width = (response.bboxes[i][2] - response.bboxes[i][0]) * image.width
val height = (response.bboxes[i][3] - response.bboxes[i][1]) * image.height // val height = (response.bboxes[i][3] - response.bboxes[i][1]) * image.height
val x = response.bboxes[i][0] * image.width // val x = response.bboxes[i][0] * image.width
val y = response.bboxes[i][1] * image.height // val y = response.bboxes[i][1] * image.height
drawer.fill = null // drawer.fill = null
drawer.stroke = ColorRGBa.PINK // drawer.stroke = ColorRGBa.PINK
drawer.rectangle(x, y, width, height) // drawer.rectangle(x, y, width, height)
drawer.stroke = null // drawer.stroke = null
drawer.fill = ColorRGBa.PINK // drawer.fill = ColorRGBa.PINK
val w = Writer(drawer) // val w = Writer(drawer)
w.box = Rectangle(x + 10.0, y + 10.0, width - 20.0, height - 20.0) // w.box = Rectangle(x + 10.0, y + 10.0, width - 20.0, height - 20.0)
w.newLine() // w.newLine()
w.text(response.classes[i]) // w.text(response.classes[i])
} // }
} // }
} // }
} //}

View File

@@ -1,26 +1,26 @@
import org.openrndr.application //import org.openrndr.application
import org.openrndr.draw.* //import org.openrndr.draw.*
import org.openrndr.extra.runway.* //import org.openrndr.extra.runway.*
//
/** ///**
* This example requires a `runway/Person-Segmentation` model to be active in Runway. // * This example requires a `runway/Person-Segmentation` model to be active in Runway.
*/ // */
fun main() = application { //fun main() = application {
configure { // configure {
width = 331 // width = 331
height = 400 // height = 400
} // }
//
program { // program {
val image = loadImage("demo-data/images/life-cover.jpg") // val image = loadImage("demo-data/images/life-cover.jpg")
//
val result: PersonSegmentationResult = // val result: PersonSegmentationResult =
runwayQuery("http://localhost:8000/query", PersonSegmentationRequest(image.toData(), 0.2)) // runwayQuery("http://localhost:8000/query", PersonSegmentationRequest(image.toData(), 0.2))
//
val segmentImage = ColorBuffer.fromData(result.image) // val segmentImage = ColorBuffer.fromData(result.image)
//
extend { // extend {
drawer.image(segmentImage, 0.0, 0.0) // drawer.image(segmentImage, 0.0, 0.0)
} // }
} // }
} //}

View File

@@ -1,36 +1,36 @@
import org.openrndr.application //import org.openrndr.application
import org.openrndr.draw.ColorBuffer //import org.openrndr.draw.ColorBuffer
import org.openrndr.extra.runway.StyleGANRequest //import org.openrndr.extra.runway.StyleGANRequest
import org.openrndr.extra.runway.StyleGANResponse //import org.openrndr.extra.runway.StyleGANResponse
import org.openrndr.extra.runway.runwayQuery //import org.openrndr.extra.runway.runwayQuery
/** ///**
* This demonstrates an image synthesizer. // * This demonstrates an image synthesizer.
* StyleGAN accepts a 512 dimensional vector from which it generates images. // * StyleGAN accepts a 512 dimensional vector from which it generates images.
* This example requires a `runway/StyleGAN` model to be active in Runway. // * This example requires a `runway/StyleGAN` model to be active in Runway.
* This also works with `eryksalvaggio/Ascinte_Seated` // * This also works with `eryksalvaggio/Ascinte_Seated`
*/ // */
fun main() = application { //fun main() = application {
configure { // configure {
width = 512 // width = 512
height = 512 // height = 512
} // }
//
program { // program {
val latentSpaceVector = MutableList(512) { Math.random() } // val latentSpaceVector = MutableList(512) { Math.random() }
//
extend { // extend {
val result: StyleGANResponse = // val result: StyleGANResponse =
runwayQuery("http://localhost:8000/query", StyleGANRequest(latentSpaceVector, 0.2)) // runwayQuery("http://localhost:8000/query", StyleGANRequest(latentSpaceVector, 0.2))
//
val image = ColorBuffer.fromUrl(result.image) // val image = ColorBuffer.fromUrl(result.image)
//
drawer.image(image, 0.0, 0.0, 512.0, 512.0) // drawer.image(image, 0.0, 0.0, 512.0, 512.0)
//
for (i in latentSpaceVector.indices) { // for (i in latentSpaceVector.indices) {
latentSpaceVector[i] += (Math.random() - 0.5) * 0.1 // latentSpaceVector[i] += (Math.random() - 0.5) * 0.1
} // }
//
image.destroy() // image.destroy()
} // }
} // }
} //}

View File

@@ -1,55 +1,55 @@
import org.openrndr.application //import org.openrndr.application
import org.openrndr.color.ColorRGBa //import org.openrndr.color.ColorRGBa
import org.openrndr.draw.Writer //import org.openrndr.draw.Writer
import org.openrndr.draw.loadFont //import org.openrndr.draw.loadFont
import org.openrndr.extra.runway.Gpt2Request //import org.openrndr.extra.runway.Gpt2Request
import org.openrndr.extra.runway.Gpt2Result //import org.openrndr.extra.runway.Gpt2Result
import org.openrndr.extra.runway.runwayQuery //import org.openrndr.extra.runway.runwayQuery
import org.openrndr.shape.Rectangle //import org.openrndr.shape.Rectangle
//
import java.io.File //import java.io.File
//
/** ///**
* This demonstrates a prompt to text model. It generates a longer text sequence from a prompt. // * This demonstrates a prompt to text model. It generates a longer text sequence from a prompt.
* This example requires a `runway/GPT-2` model to be active in Runway. // * This example requires a `runway/GPT-2` model to be active in Runway.
*/ // */
//
fun main() = application { //fun main() = application {
configure { // configure {
width = 768 // width = 768
height = 768 // height = 768
} // }
//
program { // program {
//
val runwayHost = "http://localhost:8000/query" // val runwayHost = "http://localhost:8000/query"
//
val nouns = File("demo-data/words/nouns.txt").readText().split("\n") // val nouns = File("demo-data/words/nouns.txt").readText().split("\n")
val prepositions = File("demo-data/words/prepositions.txt").readText().split("\n") // val prepositions = File("demo-data/words/prepositions.txt").readText().split("\n")
val adjectives = File("demo-data/words/adjectives.txt").readText().split("\n") // val adjectives = File("demo-data/words/adjectives.txt").readText().split("\n")
//
val font = loadFont("demo-data/fonts/IBMPlexMono-Regular.ttf", 36.0) // val font = loadFont("demo-data/fonts/IBMPlexMono-Regular.ttf", 36.0)
//
val promptFont = loadFont("demo-data/fonts/IBMPlexMono-Regular.ttf", 24.0) // val promptFont = loadFont("demo-data/fonts/IBMPlexMono-Regular.ttf", 24.0)
//
extend { // extend {
val prompt = "a ${adjectives.random()} ${nouns.random()} ${prepositions.random()} a ${adjectives.random()} ${nouns.random()}" // val prompt = "a ${adjectives.random()} ${nouns.random()} ${prepositions.random()} a ${adjectives.random()} ${nouns.random()}"
drawer.fontMap = promptFont // drawer.fontMap = promptFont
val wp = Writer(drawer) // val wp = Writer(drawer)
wp.box = Rectangle(20.0, 0.0, width - 40.0, height - 40.0) // wp.box = Rectangle(20.0, 0.0, width - 40.0, height - 40.0)
wp.newLine() // wp.newLine()
wp.text(prompt) // wp.text(prompt)
//
//
val result: Gpt2Result = runwayQuery(runwayHost, Gpt2Request(prompt, sequenceLength = 128)) // val result: Gpt2Result = runwayQuery(runwayHost, Gpt2Request(prompt, sequenceLength = 128))
//
drawer.fill = ColorRGBa.PINK // drawer.fill = ColorRGBa.PINK
drawer.fontMap = font // drawer.fontMap = font
//
val w = Writer(drawer) // val w = Writer(drawer)
w.box = Rectangle(20.0, 60.0, width - 40.0, height - 80.0) // w.box = Rectangle(20.0, 60.0, width - 40.0, height - 80.0)
w.newLine() // w.newLine()
w.text(result.text) // w.text(result.text)
} // }
} // }
} //}

View File

@@ -1,26 +1,26 @@
import org.openrndr.application //import org.openrndr.application
import org.openrndr.draw.* //import org.openrndr.draw.*
import org.openrndr.extra.runway.* //import org.openrndr.extra.runway.*
//
/** ///**
* This example requires a `runway/U-2-Net` model to be active in Runway. // * This example requires a `runway/U-2-Net` model to be active in Runway.
*/ // */
fun main() = application { //fun main() = application {
configure { // configure {
width = 305 // width = 305
height = 400 // height = 400
} // }
//
program { // program {
val image = loadImage("demo-data/images/vw-beetle.jpg") // val image = loadImage("demo-data/images/vw-beetle.jpg")
//
val result: U2NetResult = // val result: U2NetResult =
runwayQuery("http://localhost:8000/query", U2NetRequest(image.toData())) // runwayQuery("http://localhost:8000/query", U2NetRequest(image.toData()))
//
val segmentImage = ColorBuffer.fromData(result.image) // val segmentImage = ColorBuffer.fromData(result.image)
//
extend { // extend {
drawer.image(segmentImage, 0.0, 0.0) // drawer.image(segmentImage, 0.0, 0.0)
} // }
} // }
} //}