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

View File

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

View File

@@ -1,36 +1,36 @@
import org.openrndr.application
import org.openrndr.color.ColorRGBa
import org.openrndr.draw.ColorBuffer
import org.openrndr.draw.loadFont
import org.openrndr.extra.runway.AttnGANRequest
import org.openrndr.extra.runway.AttnGANResult
import org.openrndr.extra.runway.runwayQuery
import java.io.File
/**
* 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.
*/
fun main() = application {
configure {
width = 768
height = 576
}
program {
val runwayHost = "http://localhost:8000/query"
val words = File("demo-data/words/words.txt").readText().split("\n")
val font = loadFont("demo-data/fonts/IBMPlexMono-Regular.ttf", 72.0)
extend {
val text = words.random()
val result: AttnGANResult = runwayQuery(runwayHost, AttnGANRequest(text))
val image = ColorBuffer.fromUrl(result.result)
drawer.fontMap = font
drawer.image(image, (width - image.width) / 2.0, (height - image.height) / 2.0)
drawer.fill = ColorRGBa.PINK
drawer.text(text, 40.0, height / 2.0)
image.destroy()
}
}
}
//import org.openrndr.application
//import org.openrndr.color.ColorRGBa
//import org.openrndr.draw.ColorBuffer
//import org.openrndr.draw.loadFont
//import org.openrndr.extra.runway.AttnGANRequest
//import org.openrndr.extra.runway.AttnGANResult
//import org.openrndr.extra.runway.runwayQuery
//import java.io.File
//
///**
// * 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.
// */
//
//fun main() = application {
// configure {
// width = 768
// height = 576
// }
//
// program {
// val runwayHost = "http://localhost:8000/query"
// val words = File("demo-data/words/words.txt").readText().split("\n")
// val font = loadFont("demo-data/fonts/IBMPlexMono-Regular.ttf", 72.0)
// extend {
// val text = words.random()
// val result: AttnGANResult = runwayQuery(runwayHost, AttnGANRequest(text))
// val image = ColorBuffer.fromUrl(result.result)
// drawer.fontMap = font
// drawer.image(image, (width - image.width) / 2.0, (height - image.height) / 2.0)
// drawer.fill = ColorRGBa.PINK
// drawer.text(text, 40.0, height / 2.0)
// image.destroy()
// }
// }
//}

View File

@@ -1,39 +1,39 @@
import org.openrndr.application
import org.openrndr.color.ColorRGBa
import org.openrndr.draw.ColorBuffer
import org.openrndr.draw.loadFont
import org.openrndr.extra.runway.AttnGANRequest
import org.openrndr.extra.runway.AttnGANResult
import org.openrndr.extra.runway.runwayQuery
import java.io.File
/**
* 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.
*/
fun main() = application {
configure {
width = 768
height = 576
}
program {
val runwayHost = "http://localhost:8000/query"
val nouns = File("demo-data/words/nouns.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 font = loadFont("demo-data/fonts/IBMPlexMono-Regular.ttf", 36.0)
extend {
val text = "a ${adjectives.random()} ${nouns.random()} ${prepositions.random()} a ${adjectives.random()} ${nouns.random()}"
val result: AttnGANResult = runwayQuery(runwayHost, AttnGANRequest(text))
val image = ColorBuffer.fromUrl(result.result)
drawer.fontMap = font
drawer.image(image, (width - image.width) / 2.0, (height - image.height) / 2.0)
drawer.fill = ColorRGBa.PINK
drawer.text(text, 40.0, height - 40.0)
image.destroy()
}
}
}
//import org.openrndr.application
//import org.openrndr.color.ColorRGBa
//import org.openrndr.draw.ColorBuffer
//import org.openrndr.draw.loadFont
//import org.openrndr.extra.runway.AttnGANRequest
//import org.openrndr.extra.runway.AttnGANResult
//import org.openrndr.extra.runway.runwayQuery
//import java.io.File
//
///**
// * 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.
// */
//
//fun main() = application {
// configure {
// width = 768
// height = 576
// }
//
// program {
// val runwayHost = "http://localhost:8000/query"
// val nouns = File("demo-data/words/nouns.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 font = loadFont("demo-data/fonts/IBMPlexMono-Regular.ttf", 36.0)
//
// extend {
// val text = "a ${adjectives.random()} ${nouns.random()} ${prepositions.random()} a ${adjectives.random()} ${nouns.random()}"
// val result: AttnGANResult = runwayQuery(runwayHost, AttnGANRequest(text))
// val image = ColorBuffer.fromUrl(result.result)
// drawer.fontMap = font
// drawer.image(image, (width - image.width) / 2.0, (height - image.height) / 2.0)
// drawer.fill = ColorRGBa.PINK
// drawer.text(text, 40.0, height - 40.0)
// image.destroy()
// }
// }
//}

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@@ -1,55 +1,55 @@
import org.openrndr.application
import org.openrndr.color.ColorRGBa
import org.openrndr.draw.Writer
import org.openrndr.draw.loadFont
import org.openrndr.extra.runway.Gpt2Request
import org.openrndr.extra.runway.Gpt2Result
import org.openrndr.extra.runway.runwayQuery
import org.openrndr.shape.Rectangle
import java.io.File
/**
* 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.
*/
fun main() = application {
configure {
width = 768
height = 768
}
program {
val runwayHost = "http://localhost:8000/query"
val nouns = File("demo-data/words/nouns.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 font = loadFont("demo-data/fonts/IBMPlexMono-Regular.ttf", 36.0)
val promptFont = loadFont("demo-data/fonts/IBMPlexMono-Regular.ttf", 24.0)
extend {
val prompt = "a ${adjectives.random()} ${nouns.random()} ${prepositions.random()} a ${adjectives.random()} ${nouns.random()}"
drawer.fontMap = promptFont
val wp = Writer(drawer)
wp.box = Rectangle(20.0, 0.0, width - 40.0, height - 40.0)
wp.newLine()
wp.text(prompt)
val result: Gpt2Result = runwayQuery(runwayHost, Gpt2Request(prompt, sequenceLength = 128))
drawer.fill = ColorRGBa.PINK
drawer.fontMap = font
val w = Writer(drawer)
w.box = Rectangle(20.0, 60.0, width - 40.0, height - 80.0)
w.newLine()
w.text(result.text)
}
}
}
//import org.openrndr.application
//import org.openrndr.color.ColorRGBa
//import org.openrndr.draw.Writer
//import org.openrndr.draw.loadFont
//import org.openrndr.extra.runway.Gpt2Request
//import org.openrndr.extra.runway.Gpt2Result
//import org.openrndr.extra.runway.runwayQuery
//import org.openrndr.shape.Rectangle
//
//import java.io.File
//
///**
// * 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.
// */
//
//fun main() = application {
// configure {
// width = 768
// height = 768
// }
//
// program {
//
// val runwayHost = "http://localhost:8000/query"
//
// val nouns = File("demo-data/words/nouns.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 font = loadFont("demo-data/fonts/IBMPlexMono-Regular.ttf", 36.0)
//
// val promptFont = loadFont("demo-data/fonts/IBMPlexMono-Regular.ttf", 24.0)
//
// extend {
// val prompt = "a ${adjectives.random()} ${nouns.random()} ${prepositions.random()} a ${adjectives.random()} ${nouns.random()}"
// drawer.fontMap = promptFont
// val wp = Writer(drawer)
// wp.box = Rectangle(20.0, 0.0, width - 40.0, height - 40.0)
// wp.newLine()
// wp.text(prompt)
//
//
// val result: Gpt2Result = runwayQuery(runwayHost, Gpt2Request(prompt, sequenceLength = 128))
//
// drawer.fill = ColorRGBa.PINK
// drawer.fontMap = font
//
// val w = Writer(drawer)
// w.box = Rectangle(20.0, 60.0, width - 40.0, height - 80.0)
// w.newLine()
// w.text(result.text)
// }
// }
//}

View File

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