├── .classpath ├── .gitignore ├── .project ├── README.md ├── assets └── examples │ ├── ada-in-style-transfer.jpg │ ├── adaptive-style-transfer.jpg │ ├── android-sketch-permissions.jpg │ ├── arbitrary-image-stylization.jpg │ ├── attn-gan-android.png │ ├── attn-gan-raspberry-pi.jpg │ ├── attn-gan.jpg │ ├── big-gan.jpg │ ├── cn-ocr.jpg │ ├── coco-ssd.jpg │ ├── cycle-gan.jpg │ ├── de-oldify.jpg │ ├── de-raindrop.jpg │ ├── deep-lab-v3.jpg │ ├── deep-lab.jpg │ ├── deep-privacy.jpg │ ├── dense-cap.jpg │ ├── dense-depth.jpg │ ├── dense-pose.jpg │ ├── edge-connect.jpg │ ├── esrgan.jpg │ ├── face-landmarks.jpg │ ├── face-parser.jpg │ ├── face-recognition.jpg │ ├── fast-photo-style.jpg │ ├── fast-style-transfer.jpg │ ├── glow.jpg │ ├── gpt-2.jpg │ ├── im2txt.jpg │ ├── image-super-resolution.jpg │ ├── inpainting-gmcnn.jpg │ ├── mask-rcnn.jpg │ ├── mobilenet.jpg │ ├── open-gpt-2.jpg │ ├── open-pif-paf.jpg │ ├── photo-sketch.jpg │ ├── pix2pix.jpg │ ├── places-365.jpg │ ├── posenet.jpg │ ├── spade-coco.jpg │ ├── spade-landscapes.jpg │ ├── style-gan.jpg │ ├── style2paints.jpg │ ├── ugatit.jpg │ └── yolact.jpg ├── data └── README ├── examples ├── HTTP │ ├── AdaINStyleTransfer │ │ └── AdaINStyleTransfer.pde │ ├── AdaINStyleTransferFileSelect │ │ └── AdaINStyleTransferFileSelect.pde │ ├── AdaptiveStyleTransfer │ │ └── AdaptiveStyleTransfer.pde │ ├── AdaptiveStyleTransferFileSelect │ │ └── AdaptiveStyleTransferFileSelect.pde │ ├── ArbitraryImageStylization │ │ └── ArbitraryImageStylization.pde │ ├── ArbitraryImageStylizationFileSelect │ │ └── ArbitraryImageStylizationFileSelect.pde │ ├── BigGAN │ │ ├── BigGAN.pde │ │ └── data │ │ │ └── result.png │ ├── COCO_SSD │ │ └── COCO_SSD.pde │ ├── COCO_SSD_FileSelect │ │ └── COCO_SSD_FileSelect.pde │ ├── CycleGAN │ │ └── CycleGAN.pde │ ├── CycleGANFileSelect │ │ └── CycleGANFileSelect.pde │ ├── DeOldify │ │ ├── DeOldify.pde │ │ └── data │ │ │ └── GraceHopper.jpg │ ├── DeRaindropFileSelect │ │ └── DeRaindropFileSelect.pde │ ├── DeepLab │ │ └── DeepLab.pde │ ├── DeepLabFileSelect │ │ └── DeepLabFileSelect.pde │ ├── DeepLabV3FileSelect │ │ └── DeepLabV3FileSelect.pde │ ├── DeepPrivacy │ │ └── DeepPrivacy.pde │ ├── DenseCap │ │ └── DenseCap.pde │ ├── DenseCapFileSelect │ │ └── DenseCapFileSelect.pde │ ├── DenseDepth │ │ └── DenseDepth.pde │ ├── DenseDepthFileSelect │ │ └── DenseDepthFileSelect.pde │ ├── DensePose │ │ └── DensePose.pde │ ├── DensePoseFileSelect │ │ └── DensePoseFileSelect.pde │ ├── ESRGAN │ │ ├── ESRGAN.pde │ │ └── data │ │ │ └── white-tiger-128x128.jpg │ ├── EdgeConnectFileSelect │ │ └── EdgeConnectFileSelect.pde │ ├── FaceParser │ │ └── FaceParser.pde │ ├── Face_Recognition_Detect │ │ └── Face_Recognition_Detect.pde │ ├── Face_Recognition_Detect_FileSelect │ │ └── Face_Recognition_Detect_FileSelect.pde │ ├── Face_Recognition_Identify │ │ └── Face_Recognition_Identify.pde │ ├── Face_Recognition_Identify_FileSelect │ │ └── Face_Recognition_Identify_FileSelect.pde │ ├── FastPhotoStyleFileSelect │ │ └── FastPhotoStyleFileSelect.pde │ ├── FastStyleTransfer │ │ └── FastStyleTransfer.pde │ ├── FastStyleTransferFileSelect │ │ └── FastStyleTransferFileSelect.pde │ ├── FewShotFaceTranslationGANFileSelect │ │ └── FewShotFaceTranslationGANFileSelect.pde │ ├── GLOWFileSelect │ │ ├── GLOWFileSelect.pde │ │ └── Runway.pde │ ├── GPT2 │ │ └── GPT2.pde │ ├── ImageInpaintingGMCNN │ │ └── ImageInpaintingGMCNN.pde │ ├── ImageInpaintingGMCNNFileSelect │ │ └── ImageInpaintingGMCNNFileSelect.pde │ ├── ImageSuperResolution │ │ ├── ImageSuperResolution.pde │ │ └── data │ │ │ └── white-tiger-128x128.jpg │ ├── MaskRCNN │ │ └── MaskRCNN.pde │ ├── MaskRCNNFileSelect │ │ └── MaskRCNNFileSelect.pde │ ├── MobileNetFileSelect │ │ └── MobileNetFileSelect.pde │ ├── Model3DDFAFileSelect │ │ └── Model3DDFAFileSelect.pde │ ├── OpenGPT2 │ │ └── OpenGPT2.pde │ ├── OpenPifPafFull │ │ └── OpenPifPafFull.pde │ ├── OpenPifPafFullFileSelect │ │ └── OpenPifPafFullFileSelect.pde │ ├── PhotoSketch │ │ └── PhotoSketch.pde │ ├── Pix2PixFileSelect │ │ └── Pix2PixFileSelect.pde │ ├── Places365FileSelect │ │ └── Places365FileSelect.pde │ ├── PoseNetBasics │ │ └── PoseNetBasics.pde │ ├── PoseNetFull │ │ └── PoseNetFull.pde │ ├── PoseNetFullSelectImage │ │ └── PoseNetFullSelectImage.pde │ ├── PoseNetWebcam │ │ └── PoseNetWebcam.pde │ ├── ProgressiveGrowingofGANsPGAN │ │ └── ProgressiveGrowingofGANsPGAN.pde │ ├── SPADE_COCO_FileSelect │ │ ├── Runway.pde │ │ └── SPADE_COCO_FileSelect.pde │ ├── SPADE_COCO_Paint │ │ ├── Runway.pde │ │ └── SPADE_COCO_Paint.pde │ ├── SPADE_Landscapes_FileSelect │ │ ├── Runway.pde │ │ └── SPADE_Landscapes_FileSelect.pde │ ├── SPADE_Landscapes_Paint │ │ ├── Runway.pde │ │ └── SPADE_Landscapes_Paint.pde │ ├── Style2PaintsFileSelect │ │ └── Style2PaintsFileSelect.pde │ ├── StyleGAN │ │ ├── StyleGAN.pde │ │ └── StyleGAN2_RandomLatentSpaceWalk │ ├── UGATIT │ │ └── UGATIT.pde │ ├── VisualImportanceFileSelect │ │ └── VisualImportanceFileSelect.pde │ ├── YOLACT │ │ └── YOLACT.pde │ ├── YOLACTFileSelect │ │ └── YOLACTFileSelect.pde │ ├── attnGANBasics │ │ └── attnGANBasics.pde │ ├── attnGANPrompt │ │ └── attnGANPrompt.pde │ ├── cnOCR │ │ └── cnOCR.pde │ ├── face_landmarks │ │ └── face_landmarks.pde │ ├── im2txt │ │ └── im2txt.pde │ ├── im2txtFileSelect │ │ └── im2txtFileSelect.pde │ └── im2txtWebcam │ │ └── im2txtWebcam.pde ├── OSC │ ├── GPT2 │ │ └── GPT2.pde │ ├── PoseNetBasics │ │ └── PoseNetBasics.pde │ ├── PoseNetFull │ │ └── PoseNetFull.pde │ ├── PoseNetWebcam │ │ └── PoseNetWebcam.pde │ ├── attnGANBasics │ │ └── attnGANBasics.pde │ ├── face_landmarks │ │ └── face_landmarks.pde │ ├── im2txt │ │ └── im2txt.pde │ └── im2txtWebcam │ │ └── im2txtWebcam.pde ├── README └── Xtra │ ├── attnGANAndroid │ ├── AndroidManifest.xml │ ├── attnGANAndroid.pde │ ├── code │ │ └── sketch.properties │ └── sketch.properties │ └── attnGANPromptRaspberryPiZero │ ├── attnGANPromptRaspberryPiZero.pde │ └── code │ └── sketch.properties ├── lib ├── README ├── okhttp.jar └── okio.jar ├── license.txt ├── resources ├── README.md ├── build.properties ├── build.xml ├── code │ ├── ExampleTaglet.class │ ├── ExampleTaglet.java │ └── ant-contrib-1.0b3.jar ├── library.properties └── stylesheet.css ├── src └── com │ └── runwayml │ ├── ModelUtils.java │ ├── ModelUtilsAndroid.java │ ├── Runway.java │ ├── RunwayHTTP.java │ └── RunwayOSC.java └── web ├── index.html └── stylesheet.css /.classpath: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Processing library template 2 | bin 3 | tmp 4 | distribution 5 | 6 | # General 7 | .DS_Store 8 | .AppleDouble 9 | .LSOverride 10 | 11 | # Icon must end with two \r 12 | Icon 13 | 14 | # Thumbnails 15 | ._* 16 | 17 | # Files that might appear in the root of a volume 18 | .DocumentRevisions-V100 19 | .fseventsd 20 | .Spotlight-V100 21 | .TemporaryItems 22 | .Trashes 23 | .VolumeIcon.icns 24 | .com.apple.timemachine.donotpresent 25 | 26 | # Directories potentially created on remote AFP share 27 | .AppleDB 28 | .AppleDesktop 29 | Network Trash Folder 30 | Temporary Items 31 | .apdisk 32 | 33 | # Windows thumbnail cache files 34 | Thumbs.db 35 | Thumbs.db:encryptable 36 | ehthumbs.db 37 | ehthumbs_vista.db 38 | 39 | # Dump file 40 | *.stackdump 41 | 42 | # Folder config file 43 | [Dd]esktop.ini 44 | 45 | # Recycle Bin used on file shares 46 | $RECYCLE.BIN/ 47 | 48 | # Windows Installer files 49 | *.cab 50 | *.msi 51 | *.msix 52 | *.msm 53 | *.msp 54 | 55 | # Windows shortcuts 56 | *.lnk 57 | 58 | # Linux 59 | *~ 60 | 61 | # temporary files which can be created if a process still has a handle open of a deleted file 62 | .fuse_hidden* 63 | 64 | # KDE directory preferences 65 | .directory 66 | 67 | # Linux trash folder which might appear on any partition or disk 68 | .Trash-* 69 | 70 | # .nfs files are created when an open file is removed but is still being accessed 71 | .nfs* -------------------------------------------------------------------------------- /.project: -------------------------------------------------------------------------------- 1 | 2 | 3 | processing-library-template 4 | 5 | 6 | 7 | 8 | 9 | org.eclipse.jdt.core.javabuilder 10 | 11 | 12 | 13 | 14 | 15 | org.eclipse.jdt.core.javanature 16 | 17 | 18 | -------------------------------------------------------------------------------- /assets/examples/ada-in-style-transfer.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/runwayml/processing-library/ee3d79601e3539d68e43979f3b0cf4fe0d812f7c/assets/examples/ada-in-style-transfer.jpg -------------------------------------------------------------------------------- /assets/examples/adaptive-style-transfer.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/runwayml/processing-library/ee3d79601e3539d68e43979f3b0cf4fe0d812f7c/assets/examples/adaptive-style-transfer.jpg -------------------------------------------------------------------------------- /assets/examples/android-sketch-permissions.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/runwayml/processing-library/ee3d79601e3539d68e43979f3b0cf4fe0d812f7c/assets/examples/android-sketch-permissions.jpg -------------------------------------------------------------------------------- /assets/examples/arbitrary-image-stylization.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/runwayml/processing-library/ee3d79601e3539d68e43979f3b0cf4fe0d812f7c/assets/examples/arbitrary-image-stylization.jpg -------------------------------------------------------------------------------- /assets/examples/attn-gan-android.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/runwayml/processing-library/ee3d79601e3539d68e43979f3b0cf4fe0d812f7c/assets/examples/attn-gan-android.png -------------------------------------------------------------------------------- /assets/examples/attn-gan-raspberry-pi.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/runwayml/processing-library/ee3d79601e3539d68e43979f3b0cf4fe0d812f7c/assets/examples/attn-gan-raspberry-pi.jpg -------------------------------------------------------------------------------- /assets/examples/attn-gan.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/runwayml/processing-library/ee3d79601e3539d68e43979f3b0cf4fe0d812f7c/assets/examples/attn-gan.jpg -------------------------------------------------------------------------------- /assets/examples/big-gan.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/runwayml/processing-library/ee3d79601e3539d68e43979f3b0cf4fe0d812f7c/assets/examples/big-gan.jpg -------------------------------------------------------------------------------- /assets/examples/cn-ocr.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/runwayml/processing-library/ee3d79601e3539d68e43979f3b0cf4fe0d812f7c/assets/examples/cn-ocr.jpg -------------------------------------------------------------------------------- /assets/examples/coco-ssd.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/runwayml/processing-library/ee3d79601e3539d68e43979f3b0cf4fe0d812f7c/assets/examples/coco-ssd.jpg -------------------------------------------------------------------------------- /assets/examples/cycle-gan.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/runwayml/processing-library/ee3d79601e3539d68e43979f3b0cf4fe0d812f7c/assets/examples/cycle-gan.jpg -------------------------------------------------------------------------------- /assets/examples/de-oldify.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/runwayml/processing-library/ee3d79601e3539d68e43979f3b0cf4fe0d812f7c/assets/examples/de-oldify.jpg -------------------------------------------------------------------------------- /assets/examples/de-raindrop.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/runwayml/processing-library/ee3d79601e3539d68e43979f3b0cf4fe0d812f7c/assets/examples/de-raindrop.jpg -------------------------------------------------------------------------------- /assets/examples/deep-lab-v3.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/runwayml/processing-library/ee3d79601e3539d68e43979f3b0cf4fe0d812f7c/assets/examples/deep-lab-v3.jpg -------------------------------------------------------------------------------- /assets/examples/deep-lab.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/runwayml/processing-library/ee3d79601e3539d68e43979f3b0cf4fe0d812f7c/assets/examples/deep-lab.jpg -------------------------------------------------------------------------------- /assets/examples/deep-privacy.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/runwayml/processing-library/ee3d79601e3539d68e43979f3b0cf4fe0d812f7c/assets/examples/deep-privacy.jpg -------------------------------------------------------------------------------- /assets/examples/dense-cap.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/runwayml/processing-library/ee3d79601e3539d68e43979f3b0cf4fe0d812f7c/assets/examples/dense-cap.jpg -------------------------------------------------------------------------------- /assets/examples/dense-depth.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/runwayml/processing-library/ee3d79601e3539d68e43979f3b0cf4fe0d812f7c/assets/examples/dense-depth.jpg -------------------------------------------------------------------------------- /assets/examples/dense-pose.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/runwayml/processing-library/ee3d79601e3539d68e43979f3b0cf4fe0d812f7c/assets/examples/dense-pose.jpg -------------------------------------------------------------------------------- /assets/examples/edge-connect.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/runwayml/processing-library/ee3d79601e3539d68e43979f3b0cf4fe0d812f7c/assets/examples/edge-connect.jpg -------------------------------------------------------------------------------- /assets/examples/esrgan.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/runwayml/processing-library/ee3d79601e3539d68e43979f3b0cf4fe0d812f7c/assets/examples/esrgan.jpg -------------------------------------------------------------------------------- /assets/examples/face-landmarks.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/runwayml/processing-library/ee3d79601e3539d68e43979f3b0cf4fe0d812f7c/assets/examples/face-landmarks.jpg -------------------------------------------------------------------------------- /assets/examples/face-parser.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/runwayml/processing-library/ee3d79601e3539d68e43979f3b0cf4fe0d812f7c/assets/examples/face-parser.jpg -------------------------------------------------------------------------------- /assets/examples/face-recognition.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/runwayml/processing-library/ee3d79601e3539d68e43979f3b0cf4fe0d812f7c/assets/examples/face-recognition.jpg -------------------------------------------------------------------------------- /assets/examples/fast-photo-style.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/runwayml/processing-library/ee3d79601e3539d68e43979f3b0cf4fe0d812f7c/assets/examples/fast-photo-style.jpg -------------------------------------------------------------------------------- /assets/examples/fast-style-transfer.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/runwayml/processing-library/ee3d79601e3539d68e43979f3b0cf4fe0d812f7c/assets/examples/fast-style-transfer.jpg -------------------------------------------------------------------------------- /assets/examples/glow.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/runwayml/processing-library/ee3d79601e3539d68e43979f3b0cf4fe0d812f7c/assets/examples/glow.jpg -------------------------------------------------------------------------------- /assets/examples/gpt-2.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/runwayml/processing-library/ee3d79601e3539d68e43979f3b0cf4fe0d812f7c/assets/examples/gpt-2.jpg -------------------------------------------------------------------------------- /assets/examples/im2txt.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/runwayml/processing-library/ee3d79601e3539d68e43979f3b0cf4fe0d812f7c/assets/examples/im2txt.jpg -------------------------------------------------------------------------------- /assets/examples/image-super-resolution.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/runwayml/processing-library/ee3d79601e3539d68e43979f3b0cf4fe0d812f7c/assets/examples/image-super-resolution.jpg -------------------------------------------------------------------------------- /assets/examples/inpainting-gmcnn.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/runwayml/processing-library/ee3d79601e3539d68e43979f3b0cf4fe0d812f7c/assets/examples/inpainting-gmcnn.jpg -------------------------------------------------------------------------------- /assets/examples/mask-rcnn.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/runwayml/processing-library/ee3d79601e3539d68e43979f3b0cf4fe0d812f7c/assets/examples/mask-rcnn.jpg -------------------------------------------------------------------------------- /assets/examples/mobilenet.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/runwayml/processing-library/ee3d79601e3539d68e43979f3b0cf4fe0d812f7c/assets/examples/mobilenet.jpg -------------------------------------------------------------------------------- /assets/examples/open-gpt-2.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/runwayml/processing-library/ee3d79601e3539d68e43979f3b0cf4fe0d812f7c/assets/examples/open-gpt-2.jpg -------------------------------------------------------------------------------- /assets/examples/open-pif-paf.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/runwayml/processing-library/ee3d79601e3539d68e43979f3b0cf4fe0d812f7c/assets/examples/open-pif-paf.jpg -------------------------------------------------------------------------------- /assets/examples/photo-sketch.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/runwayml/processing-library/ee3d79601e3539d68e43979f3b0cf4fe0d812f7c/assets/examples/photo-sketch.jpg -------------------------------------------------------------------------------- /assets/examples/pix2pix.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/runwayml/processing-library/ee3d79601e3539d68e43979f3b0cf4fe0d812f7c/assets/examples/pix2pix.jpg -------------------------------------------------------------------------------- /assets/examples/places-365.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/runwayml/processing-library/ee3d79601e3539d68e43979f3b0cf4fe0d812f7c/assets/examples/places-365.jpg -------------------------------------------------------------------------------- /assets/examples/posenet.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/runwayml/processing-library/ee3d79601e3539d68e43979f3b0cf4fe0d812f7c/assets/examples/posenet.jpg -------------------------------------------------------------------------------- /assets/examples/spade-coco.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/runwayml/processing-library/ee3d79601e3539d68e43979f3b0cf4fe0d812f7c/assets/examples/spade-coco.jpg -------------------------------------------------------------------------------- /assets/examples/spade-landscapes.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/runwayml/processing-library/ee3d79601e3539d68e43979f3b0cf4fe0d812f7c/assets/examples/spade-landscapes.jpg -------------------------------------------------------------------------------- /assets/examples/style-gan.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/runwayml/processing-library/ee3d79601e3539d68e43979f3b0cf4fe0d812f7c/assets/examples/style-gan.jpg -------------------------------------------------------------------------------- /assets/examples/style2paints.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/runwayml/processing-library/ee3d79601e3539d68e43979f3b0cf4fe0d812f7c/assets/examples/style2paints.jpg -------------------------------------------------------------------------------- /assets/examples/ugatit.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/runwayml/processing-library/ee3d79601e3539d68e43979f3b0cf4fe0d812f7c/assets/examples/ugatit.jpg -------------------------------------------------------------------------------- /assets/examples/yolact.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/runwayml/processing-library/ee3d79601e3539d68e43979f3b0cf4fe0d812f7c/assets/examples/yolact.jpg -------------------------------------------------------------------------------- /data/README: -------------------------------------------------------------------------------- 1 | the data folder: 2 | If your Library is using files like images, sound files, 3 | any data file, etc., put them into the data folder. 4 | When coding your Library you can use processing's internal loading 5 | functions like loadImage(), loadStrings(), etc. to load files 6 | located inside the data folder into your Library. 7 | 8 | -------------------------------------------------------------------------------- /examples/HTTP/AdaptiveStyleTransfer/AdaptiveStyleTransfer.pde: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2020 RunwayML Examples 2 | // 3 | // This file is part of RunwayML Examples. 4 | // 5 | // Runway-Examples is free software: you can redistribute it and/or modify 6 | // it under the terms of the GNU General Public License as published by 7 | // the Free Software Foundation, either version 3 of the License, or 8 | // (at your option) any later version. 9 | // 10 | // Runway-Examples is distributed in the hope that it will be useful, 11 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | // GNU General Public License for more details. 14 | // 15 | // You should have received a copy of the GNU General Public License 16 | // along with RunwayML. If not, see . 17 | // 18 | // =========================================================================== 19 | 20 | // RUNWAYML 21 | // www.runwayml.com 22 | 23 | // Adaptive-Style-Transfer 24 | // Receive HTTP messages from Runway 25 | // Running Adaptive-Style-Transfer model 26 | // example by George Profenza 27 | 28 | // import video library 29 | import processing.video.*; 30 | 31 | // import Runway library 32 | import com.runwayml.*; 33 | // reference to runway instance 34 | RunwayHTTP runway; 35 | 36 | PImage runwayResult; 37 | 38 | // periocally to be updated using millis() 39 | int lastMillis; 40 | // how often should the above be updated and a time action take place ? 41 | int waitTime = 1000; 42 | 43 | // reference to the camera 44 | Capture camera; 45 | 46 | // status 47 | String status = "waiting ~"+(waitTime/1000)+"s"; 48 | 49 | void setup(){ 50 | // match sketch size to default model camera setup 51 | size(1200,400); 52 | // setup Runway 53 | runway = new RunwayHTTP(this); 54 | // update manually 55 | runway.setAutoUpdate(false); 56 | // setup camera 57 | camera = new Capture(this,640,480); 58 | camera.start(); 59 | // setup timer 60 | lastMillis = millis(); 61 | } 62 | 63 | void draw(){ 64 | background(0); 65 | // update timer 66 | int currentMillis = millis(); 67 | // if the difference between current millis and last time we checked past the wait time 68 | if(currentMillis - lastMillis >= waitTime){ 69 | status = "sending image to Runway"; 70 | // call the timed function 71 | sendFrameToRunway(); 72 | // update lastMillis, preparing for another wait 73 | lastMillis = currentMillis; 74 | } 75 | // draw image received from Runway 76 | if(runwayResult != null){ 77 | image(runwayResult,600,0); 78 | } 79 | // draw camera feed 80 | image(camera,0,0,600,400); 81 | // display status 82 | text(status,5,15); 83 | } 84 | 85 | void sendFrameToRunway(){ 86 | // nothing to send if there's no new camera data available 87 | if(camera.available() == false){ 88 | return; 89 | } 90 | // read a new frame 91 | camera.read(); 92 | // crop image to Runway input format (600x400) 93 | PImage image = camera.get(0,0,600,400); 94 | // query Runway 95 | runway.query(image,ModelUtils.IMAGE_FORMAT_JPG,"contentImage"); 96 | } 97 | 98 | // this is called when new Runway data is available 99 | void runwayDataEvent(JSONObject runwayData){ 100 | // point the sketch data to the Runway incoming data 101 | String base64ImageString = runwayData.getString("stylizedImage"); 102 | // try to decode the image from 103 | try{ 104 | runwayResult = ModelUtils.fromBase64(base64ImageString); 105 | }catch(Exception e){ 106 | e.printStackTrace(); 107 | } 108 | status = "received runway result"; 109 | } 110 | 111 | // this is called each time Processing connects to Runway 112 | // Runway sends information about the current model 113 | public void runwayInfoEvent(JSONObject info){ 114 | println(info); 115 | } 116 | // if anything goes wrong 117 | public void runwayErrorEvent(String message){ 118 | println(message); 119 | } 120 | -------------------------------------------------------------------------------- /examples/HTTP/AdaptiveStyleTransferFileSelect/AdaptiveStyleTransferFileSelect.pde: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2020 RunwayML Examples 2 | // 3 | // This file is part of RunwayML Examples. 4 | // 5 | // Runway-Examples is free software: you can redistribute it and/or modify 6 | // it under the terms of the GNU General Public License as published by 7 | // the Free Software Foundation, either version 3 of the License, or 8 | // (at your option) any later version. 9 | // 10 | // Runway-Examples is distributed in the hope that it will be useful, 11 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | // GNU General Public License for more details. 14 | // 15 | // You should have received a copy of the GNU General Public License 16 | // along with RunwayML. If not, see . 17 | // 18 | // =========================================================================== 19 | 20 | // RUNWAYML 21 | // www.runwayml.com 22 | 23 | // Adaptive-Style-Transfer 24 | // Receive HTTP messages from Runway 25 | // Running Adaptive-Style-Transfer model 26 | // example by George Profenza 27 | 28 | // import Runway library 29 | import com.runwayml.*; 30 | // reference to runway instance 31 | RunwayHTTP runway; 32 | 33 | PImage contentImage; 34 | PImage runwayResult; 35 | 36 | // status 37 | String status = "Press 'c' to select content image"; 38 | 39 | void setup(){ 40 | // match sketch size to default model camera setup 41 | size(1200,400); 42 | // setup Runway 43 | runway = new RunwayHTTP(this); 44 | // update manually 45 | runway.setAutoUpdate(false); 46 | } 47 | 48 | void draw(){ 49 | background(0); 50 | // draw content image 51 | if(contentImage != null){ 52 | image(contentImage,0,0); 53 | } 54 | // draw image received from Runway 55 | if(runwayResult != null){ 56 | image(runwayResult,600,0); 57 | } 58 | // display status 59 | text(status,5,15); 60 | } 61 | 62 | void keyPressed(){ 63 | if(key == 'c'){ 64 | selectInput("Select a content image to process:", "contentImageSelected"); 65 | } 66 | } 67 | 68 | void contentImageSelected(File selection) { 69 | if (selection == null) { 70 | println("Window was closed or the user hit cancel."); 71 | } else { 72 | println("selected " + selection.getAbsolutePath()); 73 | contentImage = loadImage(selection.getAbsolutePath()); 74 | // resize image (adjust as needed) 75 | contentImage.resize(600,400); 76 | // send it to Runway 77 | runway.query(contentImage,ModelUtils.IMAGE_FORMAT_JPG,"contentImage"); 78 | } 79 | } 80 | 81 | // this is called when new Runway data is available 82 | void runwayDataEvent(JSONObject runwayData){ 83 | // point the sketch data to the Runway incoming data 84 | String base64ImageString = runwayData.getString("stylizedImage"); 85 | // try to decode the image from 86 | try{ 87 | runwayResult = ModelUtils.fromBase64(base64ImageString); 88 | }catch(Exception e){ 89 | e.printStackTrace(); 90 | } 91 | status = "received runway result"; 92 | } 93 | 94 | // this is called each time Processing connects to Runway 95 | // Runway sends information about the current model 96 | public void runwayInfoEvent(JSONObject info){ 97 | println(info); 98 | } 99 | // if anything goes wrong 100 | public void runwayErrorEvent(String message){ 101 | println(message); 102 | } 103 | -------------------------------------------------------------------------------- /examples/HTTP/BigGAN/data/result.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/runwayml/processing-library/ee3d79601e3539d68e43979f3b0cf4fe0d812f7c/examples/HTTP/BigGAN/data/result.png -------------------------------------------------------------------------------- /examples/HTTP/COCO_SSD_FileSelect/COCO_SSD_FileSelect.pde: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2020 RunwayML Examples 2 | // 3 | // This file is part of RunwayML Examples. 4 | // 5 | // Runway-Examples is free software: you can redistribute it and/or modify 6 | // it under the terms of the GNU General Public License as published by 7 | // the Free Software Foundation, either version 3 of the License, or 8 | // (at your option) any later version. 9 | // 10 | // Runway-Examples is distributed in the hope that it will be useful, 11 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | // GNU General Public License for more details. 14 | // 15 | // You should have received a copy of the GNU General Public License 16 | // along with RunwayML. If not, see . 17 | // 18 | // =========================================================================== 19 | 20 | // RUNWAYML 21 | // www.runwayml.com 22 | 23 | // COCO-SSD Demo: 24 | // Receive HTTP messages from Runway 25 | // Running COCO-SSD model 26 | // Example by George Profenza 27 | 28 | // import Runway library 29 | import com.runwayml.*; 30 | // reference to runway instance 31 | RunwayHTTP runway; 32 | 33 | // The data coming in from Runway as a JSON Object {} 34 | JSONObject data; 35 | 36 | // status 37 | String status = "Press 'c' to select a content image"; 38 | 39 | // image to send to Runway 40 | PImage contentImage; 41 | 42 | void setup() { 43 | size(600, 400); 44 | frameRate(3); 45 | fill(255); 46 | stroke(255); 47 | // setup Runway 48 | runway = new RunwayHTTP(this); 49 | // disable automatic polling: request data manually when a new frame is ready 50 | runway.setAutoUpdate(false); 51 | } 52 | 53 | void draw() { 54 | background(0); 55 | // draw content image (if loaded) 56 | if(contentImage != null){ 57 | image(contentImage,0,0); 58 | } 59 | 60 | // Display captions 61 | drawCaptions(); 62 | 63 | // display status 64 | text(status,5,15); 65 | } 66 | 67 | 68 | void keyPressed(){ 69 | if(key == 'c'){ 70 | selectInput("Select a content image to process:", "contentImageSelected"); 71 | } 72 | } 73 | 74 | void contentImageSelected(File selection) { 75 | if (selection == null) { 76 | println("Window was closed or the user hit cancel."); 77 | } else { 78 | println("selected " + selection.getAbsolutePath()); 79 | contentImage = loadImage(selection.getAbsolutePath()); 80 | // resize image (adjust as needed) 81 | contentImage.resize(600,400); 82 | // send to Runway 83 | runway.query(contentImage); 84 | } 85 | } 86 | 87 | 88 | // A function to display the captions 89 | void drawCaptions() { 90 | // if no data is loaded yet, exit 91 | if(data == null){ 92 | return; 93 | } 94 | println(data); 95 | // access boxes and labels JSON arrays within the result 96 | JSONArray boxes = data.getJSONArray("boxes"); 97 | JSONArray labels = data.getJSONArray("labels"); 98 | // as long the array sizes match 99 | if(boxes.size() == labels.size()){ 100 | // for each array element 101 | for(int i = 0 ; i < boxes.size(); i++){ 102 | 103 | String label = labels.getString(i); 104 | JSONArray box = boxes.getJSONArray(i); 105 | // extract values from the float array 106 | float x = box.getFloat(0) * width; 107 | float y = box.getFloat(1) * height; 108 | float w = (box.getFloat(2) * width) - x; 109 | float h = (box.getFloat(3) * height) - y; 110 | // display bounding boxes 111 | noFill(); 112 | rect(x,y,w,h); 113 | fill(255); 114 | text(label,x,y); 115 | } 116 | 117 | } 118 | } 119 | 120 | // this is called when new Runway data is available 121 | void runwayDataEvent(JSONObject runwayData){ 122 | // point the sketch data to the Runway incoming data 123 | data = runwayData; 124 | } 125 | -------------------------------------------------------------------------------- /examples/HTTP/CycleGAN/CycleGAN.pde: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2020 RunwayML Examples 2 | // 3 | // This file is part of RunwayML Examples. 4 | // 5 | // Runway-Examples is free software: you can redistribute it and/or modify 6 | // it under the terms of the GNU General Public License as published by 7 | // the Free Software Foundation, either version 3 of the License, or 8 | // (at your option) any later version. 9 | // 10 | // Runway-Examples is distributed in the hope that it will be useful, 11 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | // GNU General Public License for more details. 14 | // 15 | // You should have received a copy of the GNU General Public License 16 | // along with RunwayML. If not, see . 17 | // 18 | // =========================================================================== 19 | 20 | // RUNWAYML 21 | // www.runwayml.com 22 | 23 | // CycleGAN 24 | // Receive OSC messages from Runway 25 | // Running CycleGAN model 26 | // example by George Profenza 27 | 28 | // import video library 29 | import processing.video.*; 30 | 31 | // import Runway library 32 | import com.runwayml.*; 33 | // reference to runway instance 34 | RunwayHTTP runway; 35 | 36 | PImage runwayResult; 37 | 38 | // periocally to be updated using millis() 39 | int lastMillis; 40 | // how often should the above be updated and a time action take place ? 41 | int waitTime = 1000; 42 | 43 | // reference to the camera 44 | Capture camera; 45 | 46 | // status 47 | String status = "waiting ~"+(waitTime/1000)+"s"; 48 | 49 | void setup(){ 50 | // match sketch size to default model camera setup 51 | size(1200,400); 52 | // setup Runway 53 | runway = new RunwayHTTP(this); 54 | // update manually 55 | runway.setAutoUpdate(false); 56 | // setup camera 57 | camera = new Capture(this,640,480); 58 | camera.start(); 59 | // setup timer 60 | lastMillis = millis(); 61 | } 62 | 63 | void draw(){ 64 | background(0); 65 | // update timer 66 | int currentMillis = millis(); 67 | // if the difference between current millis and last time we checked past the wait time 68 | if(currentMillis - lastMillis >= waitTime){ 69 | status = "sending image to Runway"; 70 | // call the timed function 71 | sendFrameToRunway(); 72 | // update lastMillis, preparing for another wait 73 | lastMillis = currentMillis; 74 | } 75 | // draw image received from Runway 76 | if(runwayResult != null){ 77 | image(runwayResult,600,0); 78 | } 79 | // draw camera feed 80 | image(camera,0,0,600,400); 81 | // display status 82 | text(status,5,15); 83 | } 84 | 85 | void sendFrameToRunway(){ 86 | // nothing to send if there's no new camera data available 87 | if(camera.available() == false){ 88 | return; 89 | } 90 | // read a new frame 91 | camera.read(); 92 | // crop image to Runway input format (600x400) 93 | PImage image = camera.get(0,0,600,400); 94 | // query Runway with webcam image 95 | runway.query(image); 96 | } 97 | 98 | 99 | // this is called when new Runway data is available 100 | void runwayDataEvent(JSONObject runwayData){ 101 | // point the sketch data to the Runway incoming data 102 | String base64ImageString = runwayData.getString("image"); 103 | // try to decode the image from 104 | try{ 105 | runwayResult = ModelUtils.fromBase64(base64ImageString); 106 | }catch(Exception e){ 107 | e.printStackTrace(); 108 | } 109 | status = "received runway result"; 110 | } 111 | 112 | // this is called each time Processing connects to Runway 113 | // Runway sends information about the current model 114 | public void runwayInfoEvent(JSONObject info){ 115 | println(info); 116 | } 117 | // if anything goes wrong 118 | public void runwayErrorEvent(String message){ 119 | println(message); 120 | } 121 | -------------------------------------------------------------------------------- /examples/HTTP/CycleGANFileSelect/CycleGANFileSelect.pde: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2020 RunwayML Examples 2 | // 3 | // This file is part of RunwayML Examples. 4 | // 5 | // Runway-Examples is free software: you can redistribute it and/or modify 6 | // it under the terms of the GNU General Public License as published by 7 | // the Free Software Foundation, either version 3 of the License, or 8 | // (at your option) any later version. 9 | // 10 | // Runway-Examples is distributed in the hope that it will be useful, 11 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | // GNU General Public License for more details. 14 | // 15 | // You should have received a copy of the GNU General Public License 16 | // along with RunwayML. If not, see . 17 | // 18 | // =========================================================================== 19 | 20 | // RUNWAYML 21 | // www.runwayml.com 22 | 23 | // CycleGAN 24 | // Receive OSC messages from Runway 25 | // Running CycleGAN model 26 | // example by George Profenza 27 | 28 | // import Runway library 29 | import com.runwayml.*; 30 | // reference to runway instance 31 | RunwayHTTP runway; 32 | 33 | PImage runwayResult; 34 | // status 35 | String status = "Press 'c' to select a content image"; 36 | // image to send to Runway 37 | PImage contentImage; 38 | 39 | void setup(){ 40 | // match sketch size to default model camera setup 41 | size(1200,400); 42 | // setup Runway 43 | runway = new RunwayHTTP(this); 44 | // update manually 45 | runway.setAutoUpdate(false); 46 | 47 | } 48 | 49 | void draw(){ 50 | background(0); 51 | // draw content image (if loaded) 52 | if(contentImage != null){ 53 | image(contentImage,0,0); 54 | } 55 | 56 | // draw image received from Runway 57 | if(runwayResult != null){ 58 | image(runwayResult,600,0); 59 | } 60 | 61 | // display status 62 | text(status,5,15); 63 | } 64 | 65 | void keyPressed(){ 66 | if(key == 'c'){ 67 | selectInput("Select a content image to process:", "contentImageSelected"); 68 | } 69 | } 70 | 71 | void contentImageSelected(File selection) { 72 | if (selection == null) { 73 | println("Window was closed or the user hit cancel."); 74 | } else { 75 | println("selected " + selection.getAbsolutePath()); 76 | contentImage = loadImage(selection.getAbsolutePath()); 77 | // resize image (adjust as needed) 78 | contentImage.resize(600,400); 79 | // send to Runway 80 | runway.query(contentImage); 81 | } 82 | } 83 | 84 | // this is called when new Runway data is available 85 | void runwayDataEvent(JSONObject runwayData){ 86 | // point the sketch data to the Runway incoming data 87 | String base64ImageString = runwayData.getString("image"); 88 | // try to decode the image from 89 | try{ 90 | runwayResult = ModelUtils.fromBase64(base64ImageString); 91 | }catch(Exception e){ 92 | e.printStackTrace(); 93 | } 94 | status = "received runway result"; 95 | } 96 | 97 | // this is called each time Processing connects to Runway 98 | // Runway sends information about the current model 99 | public void runwayInfoEvent(JSONObject info){ 100 | println(info); 101 | } 102 | // if anything goes wrong 103 | public void runwayErrorEvent(String message){ 104 | println(message); 105 | } 106 | -------------------------------------------------------------------------------- /examples/HTTP/DeOldify/DeOldify.pde: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2020 RunwayML Examples 2 | // 3 | // This file is part of RunwayML Examples. 4 | // 5 | // Runway-Examples is free software: you can redistribute it and/or modify 6 | // it under the terms of the GNU General Public License as published by 7 | // the Free Software Foundation, either version 3 of the License, or 8 | // (at your option) any later version. 9 | // 10 | // Runway-Examples is distributed in the hope that it will be useful, 11 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | // GNU General Public License for more details. 14 | // 15 | // You should have received a copy of the GNU General Public License 16 | // along with RunwayML. If not, see . 17 | // 18 | // =========================================================================== 19 | 20 | // RUNWAYML 21 | // www.runwayml.com 22 | 23 | // DeOldify Demo: 24 | // Receive HTTP messages from Runway 25 | // Running DeOldify model 26 | // example by George Profenza 27 | // image credits: Courtesy of the Computer History Museum, source: https://news.yale.edu/2017/02/10/grace-murray-hopper-1906-1992-legacy-innovation-and-service 28 | 29 | // import Runway library 30 | import com.runwayml.*; 31 | // reference to runway instance 32 | RunwayHTTP runway; 33 | 34 | PImage inputImage; 35 | PImage outputImage; 36 | 37 | String status = ""; 38 | 39 | void setup() { 40 | size(1150, 334); 41 | noSmooth(); 42 | // setup Runway 43 | runway = new RunwayHTTP(this); 44 | // disable automatic polling: request data manually when a new frame is ready 45 | runway.setAutoUpdate(false); 46 | // load example image: feel free to replace with yours 47 | inputImage = loadImage("GraceHopper.jpg"); 48 | } 49 | 50 | void draw() { 51 | background(0); 52 | // draw input image (if any) 53 | if(outputImage != null){ 54 | image(outputImage,575,0); 55 | } 56 | // draw webcam image 57 | image(inputImage,0,0); 58 | // draw instructions 59 | text("press SPACE to send image to Runway\n" + status,5,15); 60 | } 61 | 62 | void keyPressed(){ 63 | if(key == ' '){ 64 | status = "processing data"; 65 | // send inputImage to Runway 66 | runway.query(inputImage); 67 | } 68 | } 69 | 70 | // this is called when new Runway data is available 71 | void runwayDataEvent(JSONObject runwayData){ 72 | // extract Base64 encoded image from JSON object and decode it to a PImage 73 | try{ 74 | outputImage = ModelUtils.fromBase64(runwayData.getString("image")); 75 | status = "processing complete"; 76 | }catch(Exception e){ 77 | println("error parsing runway Data:\n" + runwayData.toString()); 78 | e.printStackTrace(); 79 | } 80 | } 81 | -------------------------------------------------------------------------------- /examples/HTTP/DeOldify/data/GraceHopper.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/runwayml/processing-library/ee3d79601e3539d68e43979f3b0cf4fe0d812f7c/examples/HTTP/DeOldify/data/GraceHopper.jpg -------------------------------------------------------------------------------- /examples/HTTP/DeRaindropFileSelect/DeRaindropFileSelect.pde: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2020 RunwayML Examples 2 | // 3 | // This file is part of RunwayML Examples. 4 | // 5 | // Runway-Examples is free software: you can redistribute it and/or modify 6 | // it under the terms of the GNU General Public License as published by 7 | // the Free Software Foundation, either version 3 of the License, or 8 | // (at your option) any later version. 9 | // 10 | // Runway-Examples is distributed in the hope that it will be useful, 11 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | // GNU General Public License for more details. 14 | // 15 | // You should have received a copy of the GNU General Public License 16 | // along with RunwayML. If not, see . 17 | // 18 | // =========================================================================== 19 | 20 | // RUNWAYML 21 | // www.runwayml.com 22 | 23 | // DeRaindrop 24 | // Receive HTTP messages from Runway 25 | // Running DeRaindrop model 26 | // example by George Profenza 27 | 28 | // import Runway library 29 | import com.runwayml.*; 30 | // reference to runway instance 31 | RunwayHTTP runway; 32 | 33 | PImage runwayResult; 34 | PImage contentImage; 35 | 36 | // status 37 | String status = "Press 'c' to select a content image"; 38 | 39 | void setup(){ 40 | // match sketch size to default model camera setup 41 | size(792,600); 42 | // setup Runway 43 | runway = new RunwayHTTP(this); 44 | // update manually 45 | runway.setAutoUpdate(false); 46 | } 47 | 48 | void draw(){ 49 | background(0); 50 | // draw content image (if loaded) 51 | if(contentImage != null){ 52 | image(contentImage,0,0); 53 | } 54 | // draw image received from Runway 55 | if(runwayResult != null){ 56 | image(runwayResult,396,0); 57 | } 58 | // display status 59 | text(status,5,15); 60 | } 61 | 62 | void keyPressed(){ 63 | if(key == 'c'){ 64 | selectInput("Select a content image to process:", "contentImageSelected"); 65 | } 66 | if(key == 's'){ 67 | if(runwayResult != null){ 68 | runwayResult.save(dataPath("result.png")); 69 | } 70 | } 71 | } 72 | 73 | void contentImageSelected(File selection) { 74 | if (selection == null) { 75 | println("Window was closed or the user hit cancel."); 76 | } else { 77 | println("selected " + selection.getAbsolutePath()); 78 | contentImage = loadImage(selection.getAbsolutePath()); 79 | // send to Runway 80 | runway.query(contentImage,ModelUtils.IMAGE_FORMAT_JPG,"input_image"); 81 | } 82 | } 83 | 84 | // this is called when new Runway data is available 85 | void runwayDataEvent(JSONObject runwayData){ 86 | // point the sketch data to the Runway incoming data 87 | String base64ImageString = runwayData.getString("output_image"); 88 | // try to decode the image from 89 | try{ 90 | runwayResult = ModelUtils.fromBase64(base64ImageString); 91 | }catch(Exception e){ 92 | e.printStackTrace(); 93 | } 94 | status = "received runway result"; 95 | } 96 | 97 | // this is called each time Processing connects to Runway 98 | // Runway sends information about the current model 99 | public void runwayInfoEvent(JSONObject info){ 100 | println(info); 101 | } 102 | // if anything goes wrong 103 | public void runwayErrorEvent(String message){ 104 | println(message); 105 | } 106 | -------------------------------------------------------------------------------- /examples/HTTP/DeepLab/DeepLab.pde: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2020 RunwayML Examples 2 | // 3 | // This file is part of RunwayML Examples. 4 | // 5 | // Runway-Examples is free software: you can redistribute it and/or modify 6 | // it under the terms of the GNU General Public License as published by 7 | // the Free Software Foundation, either version 3 of the License, or 8 | // (at your option) any later version. 9 | // 10 | // Runway-Examples is distributed in the hope that it will be useful, 11 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | // GNU General Public License for more details. 14 | // 15 | // You should have received a copy of the GNU General Public License 16 | // along with RunwayML. If not, see . 17 | // 18 | // =========================================================================== 19 | 20 | // RUNWAYML 21 | // www.runwayml.com 22 | 23 | // DeepLab 24 | // Receive HTTP messages from Runway 25 | // Running DeepLab model 26 | // example by George Profenza 27 | 28 | // import video library 29 | import processing.video.*; 30 | 31 | // import Runway library 32 | import com.runwayml.*; 33 | // reference to runway instance 34 | RunwayHTTP runway; 35 | 36 | PImage runwayResult; 37 | 38 | // periocally to be updated using millis() 39 | int lastMillis; 40 | // how often should the above be updated and a time action take place ? 41 | int waitTime = 1000; 42 | 43 | // reference to the camera 44 | Capture camera; 45 | 46 | // status 47 | String status = "waiting ~"+(waitTime/1000)+"s"; 48 | 49 | void setup(){ 50 | // match sketch size to default model camera setup 51 | size(1200,400); 52 | // setup Runway 53 | runway = new RunwayHTTP(this); 54 | // update manually 55 | runway.setAutoUpdate(false); 56 | // setup camera 57 | camera = new Capture(this,640,480); 58 | camera.start(); 59 | // setup timer 60 | lastMillis = millis(); 61 | } 62 | 63 | void draw(){ 64 | background(0); 65 | // update timer 66 | int currentMillis = millis(); 67 | // if the difference between current millis and last time we checked past the wait time 68 | if(currentMillis - lastMillis >= waitTime){ 69 | status = "sending image to Runway"; 70 | // call the timed function 71 | sendFrameToRunway(); 72 | // update lastMillis, preparing for another wait 73 | lastMillis = currentMillis; 74 | } 75 | // draw image received from Runway 76 | if(runwayResult != null){ 77 | image(runwayResult,600,0); 78 | } 79 | // draw camera feed 80 | image(camera,0,0,600,400); 81 | // display status 82 | text(status,5,15); 83 | } 84 | 85 | void sendFrameToRunway(){ 86 | // nothing to send if there's no new camera data available 87 | if(camera.available() == false){ 88 | return; 89 | } 90 | // read a new frame 91 | camera.read(); 92 | // crop image to Runway input format (600x400) 93 | PImage image = camera.get(0,0,600,400); 94 | // query Runway 95 | runway.query(image); 96 | } 97 | 98 | // this is called when new Runway data is available 99 | void runwayDataEvent(JSONObject runwayData){ 100 | // point the sketch data to the Runway incoming data 101 | String base64ImageString = runwayData.getString("image"); 102 | // try to decode the image from 103 | try{ 104 | runwayResult = ModelUtils.fromBase64(base64ImageString); 105 | }catch(Exception e){ 106 | e.printStackTrace(); 107 | } 108 | status = "received runway result"; 109 | } 110 | 111 | // this is called each time Processing connects to Runway 112 | // Runway sends information about the current model 113 | public void runwayInfoEvent(JSONObject info){ 114 | println(info); 115 | } 116 | // if anything goes wrong 117 | public void runwayErrorEvent(String message){ 118 | println(message); 119 | } 120 | -------------------------------------------------------------------------------- /examples/HTTP/DeepLabFileSelect/DeepLabFileSelect.pde: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2020 RunwayML Examples 2 | // 3 | // This file is part of RunwayML Examples. 4 | // 5 | // Runway-Examples is free software: you can redistribute it and/or modify 6 | // it under the terms of the GNU General Public License as published by 7 | // the Free Software Foundation, either version 3 of the License, or 8 | // (at your option) any later version. 9 | // 10 | // Runway-Examples is distributed in the hope that it will be useful, 11 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | // GNU General Public License for more details. 14 | // 15 | // You should have received a copy of the GNU General Public License 16 | // along with RunwayML. If not, see . 17 | // 18 | // =========================================================================== 19 | 20 | // RUNWAYML 21 | // www.runwayml.com 22 | 23 | // DeepLab 24 | // Receive HTTP messages from Runway 25 | // Running DeepLab model 26 | // example by George Profenza 27 | 28 | // import Runway library 29 | import com.runwayml.*; 30 | // reference to runway instance 31 | RunwayHTTP runway; 32 | 33 | PImage runwayResult; 34 | PImage contentImage; 35 | 36 | // status 37 | String status = "Press 'c' to select a content image"; 38 | 39 | void setup(){ 40 | // match sketch size to default model camera setup 41 | size(1200,400); 42 | // setup Runway 43 | runway = new RunwayHTTP(this); 44 | // update manually 45 | runway.setAutoUpdate(false); 46 | } 47 | 48 | void draw(){ 49 | background(0); 50 | // draw content image (if loaded) 51 | if(contentImage != null){ 52 | image(contentImage,0,0); 53 | } 54 | // draw image received from Runway 55 | if(runwayResult != null){ 56 | image(runwayResult,600,0); 57 | } 58 | // display status 59 | text(status,5,15); 60 | } 61 | 62 | void keyPressed(){ 63 | if(key == 'c'){ 64 | selectInput("Select a content image to process:", "contentImageSelected"); 65 | } 66 | if(key == 's'){ 67 | if(runwayResult != null){ 68 | runwayResult.save(dataPath("result.png")); 69 | } 70 | } 71 | } 72 | 73 | void contentImageSelected(File selection) { 74 | if (selection == null) { 75 | println("Window was closed or the user hit cancel."); 76 | } else { 77 | println("selected " + selection.getAbsolutePath()); 78 | contentImage = loadImage(selection.getAbsolutePath()); 79 | // resize image (adjust as needed) 80 | contentImage.resize(600,400); 81 | // send to Runway 82 | runway.query(contentImage); 83 | } 84 | } 85 | 86 | // this is called when new Runway data is available 87 | void runwayDataEvent(JSONObject runwayData){ 88 | // point the sketch data to the Runway incoming data 89 | String base64ImageString = runwayData.getString("image"); 90 | // try to decode the image from 91 | try{ 92 | runwayResult = ModelUtils.fromBase64(base64ImageString); 93 | }catch(Exception e){ 94 | e.printStackTrace(); 95 | } 96 | status = "received runway result"; 97 | } 98 | 99 | // this is called each time Processing connects to Runway 100 | // Runway sends information about the current model 101 | public void runwayInfoEvent(JSONObject info){ 102 | println(info); 103 | } 104 | // if anything goes wrong 105 | public void runwayErrorEvent(String message){ 106 | println(message); 107 | } 108 | -------------------------------------------------------------------------------- /examples/HTTP/DeepLabV3FileSelect/DeepLabV3FileSelect.pde: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2020 RunwayML Examples 2 | // 3 | // This file is part of RunwayML Examples. 4 | // 5 | // Runway-Examples is free software: you can redistribute it and/or modify 6 | // it under the terms of the GNU General Public License as published by 7 | // the Free Software Foundation, either version 3 of the License, or 8 | // (at your option) any later version. 9 | // 10 | // Runway-Examples is distributed in the hope that it will be useful, 11 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | // GNU General Public License for more details. 14 | // 15 | // You should have received a copy of the GNU General Public License 16 | // along with RunwayML. If not, see . 17 | // 18 | // =========================================================================== 19 | 20 | // RUNWAYML 21 | // www.runwayml.com 22 | 23 | // DeepLabV3 24 | // Receive HTTP messages from Runway 25 | // Running DeepLabV3 model 26 | // example by George Profenza 27 | 28 | // import Runway library 29 | import com.runwayml.*; 30 | // reference to runway instance 31 | RunwayHTTP runway; 32 | 33 | PImage runwayResult; 34 | PImage contentImage; 35 | 36 | // status 37 | String status = "Press 'c' to select a content image"; 38 | 39 | void setup(){ 40 | // match sketch size to default model camera setup 41 | size(1200,400); 42 | // setup Runway 43 | runway = new RunwayHTTP(this); 44 | // update manually 45 | runway.setAutoUpdate(false); 46 | } 47 | 48 | void draw(){ 49 | background(0); 50 | // draw content image (if loaded) 51 | if(contentImage != null){ 52 | image(contentImage,0,0); 53 | } 54 | // draw image received from Runway 55 | if(runwayResult != null){ 56 | image(runwayResult,600,0); 57 | } 58 | // display status 59 | text(status,5,15); 60 | } 61 | 62 | void keyPressed(){ 63 | if(key == 'c'){ 64 | selectInput("Select a content image to process:", "contentImageSelected"); 65 | } 66 | if(key == 's'){ 67 | if(runwayResult != null){ 68 | runwayResult.save(dataPath("result.png")); 69 | } 70 | } 71 | } 72 | 73 | void contentImageSelected(File selection) { 74 | if (selection == null) { 75 | println("Window was closed or the user hit cancel."); 76 | } else { 77 | println("selected " + selection.getAbsolutePath()); 78 | contentImage = loadImage(selection.getAbsolutePath()); 79 | // resize image (adjust as needed) 80 | contentImage.resize(600,400); 81 | // send to Runway 82 | runway.query(contentImage); 83 | } 84 | } 85 | 86 | // this is called when new Runway data is available 87 | void runwayDataEvent(JSONObject runwayData){ 88 | // point the sketch data to the Runway incoming data 89 | String base64ImageString = runwayData.getString("segmentation"); 90 | // try to decode the image from 91 | try{ 92 | runwayResult = ModelUtils.fromBase64(base64ImageString); 93 | }catch(Exception e){ 94 | e.printStackTrace(); 95 | } 96 | status = "received runway result"; 97 | } 98 | 99 | // this is called each time Processing connects to Runway 100 | // Runway sends information about the current model 101 | public void runwayInfoEvent(JSONObject info){ 102 | println(info); 103 | } 104 | // if anything goes wrong 105 | public void runwayErrorEvent(String message){ 106 | println(message); 107 | } 108 | -------------------------------------------------------------------------------- /examples/HTTP/DeepPrivacy/DeepPrivacy.pde: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2020 RunwayML Examples 2 | // 3 | // This file is part of RunwayML Examples. 4 | // 5 | // Runway-Examples is free software: you can redistribute it and/or modify 6 | // it under the terms of the GNU General Public License as published by 7 | // the Free Software Foundation, either version 3 of the License, or 8 | // (at your option) any later version. 9 | // 10 | // Runway-Examples is distributed in the hope that it will be useful, 11 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | // GNU General Public License for more details. 14 | // 15 | // You should have received a copy of the GNU General Public License 16 | // along with RunwayML. If not, see . 17 | // 18 | // =========================================================================== 19 | 20 | // RUNWAYML 21 | // www.runwayml.com 22 | 23 | // DeepPrivacy 24 | // Receive HTTP messages from Runway 25 | // Running DeepPrivacy model 26 | // example by George Profenza 27 | 28 | // import Runway library 29 | import com.runwayml.*; 30 | // reference to runway instance 31 | RunwayHTTP runway; 32 | 33 | PImage runwayResult; 34 | PImage contentImage; 35 | 36 | // status 37 | String status = "Press 'c' to select a content image"; 38 | 39 | void setup(){ 40 | // match sketch size to default model camera setup 41 | size(1200,400); 42 | // setup Runway 43 | runway = new RunwayHTTP(this); 44 | // update manually 45 | runway.setAutoUpdate(false); 46 | } 47 | 48 | void draw(){ 49 | background(0); 50 | // draw content image (if loaded) 51 | if(contentImage != null){ 52 | image(contentImage,0,0); 53 | } 54 | // draw image received from Runway 55 | if(runwayResult != null){ 56 | image(runwayResult,600,0); 57 | } 58 | // display status 59 | text(status,5,15); 60 | } 61 | 62 | void keyPressed(){ 63 | if(key == 'c'){ 64 | selectInput("Select a content image to process:", "contentImageSelected"); 65 | } 66 | if(key == 's'){ 67 | if(runwayResult != null){ 68 | runwayResult.save(dataPath("result.png")); 69 | } 70 | } 71 | } 72 | 73 | void contentImageSelected(File selection) { 74 | if (selection == null) { 75 | println("Window was closed or the user hit cancel."); 76 | } else { 77 | println("selected " + selection.getAbsolutePath()); 78 | contentImage = loadImage(selection.getAbsolutePath()); 79 | // resize image (adjust as needed) 80 | contentImage.resize(600,400); 81 | // send to Runway 82 | runway.query(contentImage); 83 | } 84 | } 85 | 86 | // this is called when new Runway data is available 87 | void runwayDataEvent(JSONObject runwayData){ 88 | // point the sketch data to the Runway incoming data 89 | String base64ImageString = runwayData.getString("anonymized_image"); 90 | // try to decode the image from 91 | try{ 92 | runwayResult = ModelUtils.fromBase64(base64ImageString); 93 | }catch(Exception e){ 94 | e.printStackTrace(); 95 | } 96 | status = "received runway result"; 97 | } 98 | 99 | // this is called each time Processing connects to Runway 100 | // Runway sends information about the current model 101 | public void runwayInfoEvent(JSONObject info){ 102 | println(info); 103 | } 104 | // if anything goes wrong 105 | public void runwayErrorEvent(String message){ 106 | println(message); 107 | } 108 | -------------------------------------------------------------------------------- /examples/HTTP/DenseCapFileSelect/DenseCapFileSelect.pde: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2020 RunwayML Examples 2 | // 3 | // This file is part of RunwayML Examples. 4 | // 5 | // Runway-Examples is free software: you can redistribute it and/or modify 6 | // it under the terms of the GNU General Public License as published by 7 | // the Free Software Foundation, either version 3 of the License, or 8 | // (at your option) any later version. 9 | // 10 | // Runway-Examples is distributed in the hope that it will be useful, 11 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | // GNU General Public License for more details. 14 | // 15 | // You should have received a copy of the GNU General Public License 16 | // along with RunwayML. If not, see . 17 | // 18 | // =========================================================================== 19 | 20 | // RUNWAYML 21 | // www.runwayml.com 22 | 23 | // COCO-SSD Demo: 24 | // Receive HTTP messages from Runway 25 | // Running COCO-SSD model 26 | // example by George Profenza 27 | 28 | // import Runway library 29 | import com.runwayml.*; 30 | // reference to runway instance 31 | RunwayHTTP runway; 32 | 33 | // The data coming in from Runway as a JSON Object {} 34 | JSONObject data; 35 | 36 | String status = "Press 'c' to select a content image"; 37 | // image to send to Runway 38 | PImage contentImage; 39 | 40 | void setup() { 41 | size(600, 400); 42 | frameRate(3); 43 | fill(255); 44 | stroke(255); 45 | // setup Runway 46 | runway = new RunwayHTTP(this); 47 | // disable automatic polling: request data manually when a new frame is ready 48 | runway.setAutoUpdate(false); 49 | 50 | } 51 | 52 | void draw() { 53 | background(0); 54 | // draw content image (if loaded) 55 | if(contentImage != null){ 56 | image(contentImage,0,0); 57 | } 58 | 59 | // Display captions 60 | drawCaptions(); 61 | 62 | // display status 63 | text(status,5,15); 64 | } 65 | 66 | void keyPressed(){ 67 | if(key == 'c'){ 68 | selectInput("Select a content image to process:", "contentImageSelected"); 69 | } 70 | } 71 | 72 | void contentImageSelected(File selection) { 73 | if (selection == null) { 74 | println("Window was closed or the user hit cancel."); 75 | } else { 76 | println("selected " + selection.getAbsolutePath()); 77 | contentImage = loadImage(selection.getAbsolutePath()); 78 | // resize image (adjust as needed) 79 | contentImage.resize(600,400); 80 | // send to Runway 81 | runway.query(contentImage); 82 | } 83 | } 84 | 85 | 86 | 87 | // A function to display the captions 88 | void drawCaptions() { 89 | // if no data is loaded yet, exit 90 | if(data == null){ 91 | return; 92 | } 93 | 94 | // for each array element 95 | for (int i = 0; i < data.size(); i++) { 96 | 97 | JSONArray className = data.getJSONArray("classes"); 98 | JSONArray score = data.getJSONArray("scores"); 99 | JSONArray boxes = data.getJSONArray("bboxes"); 100 | 101 | String label = className.getString(i); 102 | float val=score.getFloat(i); 103 | JSONArray box = boxes.getJSONArray(i); 104 | // extract values from the float array 105 | float x = box.getFloat(0)* width; 106 | float y = box.getFloat(1)* height; 107 | float w = (box.getFloat(2) * width) - x; 108 | float h = (box.getFloat(3) * height) - y; 109 | 110 | // display bounding boxes 111 | noFill(); 112 | rect(x, y, w, h); 113 | fill(255); 114 | text(label + " score: " + String.format("%.2f", val), x, y); 115 | 116 | } 117 | } 118 | 119 | // this is called when new Runway data is available 120 | void runwayDataEvent(JSONObject runwayData){ 121 | // point the sketch data to the Runway incoming data 122 | data = runwayData; 123 | } 124 | -------------------------------------------------------------------------------- /examples/HTTP/DenseDepth/DenseDepth.pde: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2020 RunwayML Examples 2 | // 3 | // This file is part of RunwayML Examples. 4 | // 5 | // Runway-Examples is free software: you can redistribute it and/or modify 6 | // it under the terms of the GNU General Public License as published by 7 | // the Free Software Foundation, either version 3 of the License, or 8 | // (at your option) any later version. 9 | // 10 | // Runway-Examples is distributed in the hope that it will be useful, 11 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | // GNU General Public License for more details. 14 | // 15 | // You should have received a copy of the GNU General Public License 16 | // along with RunwayML. If not, see . 17 | // 18 | // =========================================================================== 19 | 20 | // RUNWAYML 21 | // www.runwayml.com 22 | 23 | // DenseDepth 24 | // Receive HTTP messages from Runway 25 | // Running DenseDepth model 26 | // example by George Profenza 27 | 28 | // import video library 29 | import processing.video.*; 30 | 31 | // import Runway library 32 | import com.runwayml.*; 33 | // reference to runway instance 34 | RunwayHTTP runway; 35 | 36 | PImage runwayResult; 37 | 38 | // periocally to be updated using millis() 39 | int lastMillis; 40 | // how often should the above be updated and a time action take place ? 41 | int waitTime = 1000; 42 | 43 | // reference to the camera 44 | Capture camera; 45 | 46 | // status 47 | String status = "waiting ~"+(waitTime/1000)+"s"; 48 | 49 | void setup(){ 50 | // match sketch size to default model camera setup 51 | size(1200,400); 52 | // setup Runway 53 | runway = new RunwayHTTP(this); 54 | // update manually 55 | runway.setAutoUpdate(false); 56 | // setup camera 57 | camera = new Capture(this,640,480); 58 | camera.start(); 59 | // setup timer 60 | lastMillis = millis(); 61 | } 62 | 63 | void draw(){ 64 | background(0); 65 | // update timer 66 | int currentMillis = millis(); 67 | // if the difference between current millis and last time we checked past the wait time 68 | if(currentMillis - lastMillis >= waitTime){ 69 | status = "sending image to Runway"; 70 | // call the timed function 71 | sendFrameToRunway(); 72 | // update lastMillis, preparing for another wait 73 | lastMillis = currentMillis; 74 | } 75 | // draw image received from Runway 76 | if(runwayResult != null){ 77 | image(runwayResult,600,0); 78 | } 79 | // draw camera feed 80 | image(camera,0,0,600,400); 81 | // display status 82 | text(status,5,15); 83 | } 84 | 85 | void sendFrameToRunway(){ 86 | // nothing to send if there's no new camera data available 87 | if(camera.available() == false){ 88 | return; 89 | } 90 | // read a new frame 91 | camera.read(); 92 | // crop image to Runway input format (600x400) 93 | PImage image = camera.get(0,0,600,400); 94 | // query Runway 95 | runway.query(image); 96 | } 97 | 98 | // this is called when new Runway data is available 99 | void runwayDataEvent(JSONObject runwayData){ 100 | // point the sketch data to the Runway incoming data 101 | String base64ImageString = runwayData.getString("depth_image"); 102 | // try to decode the image from 103 | try{ 104 | runwayResult = ModelUtils.fromBase64(base64ImageString); 105 | }catch(Exception e){ 106 | e.printStackTrace(); 107 | } 108 | status = "received runway result"; 109 | } 110 | 111 | // this is called each time Processing connects to Runway 112 | // Runway sends information about the current model 113 | public void runwayInfoEvent(JSONObject info){ 114 | println(info); 115 | } 116 | // if anything goes wrong 117 | public void runwayErrorEvent(String message){ 118 | println(message); 119 | } 120 | -------------------------------------------------------------------------------- /examples/HTTP/DenseDepthFileSelect/DenseDepthFileSelect.pde: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2020 RunwayML Examples 2 | // 3 | // This file is part of RunwayML Examples. 4 | // 5 | // Runway-Examples is free software: you can redistribute it and/or modify 6 | // it under the terms of the GNU General Public License as published by 7 | // the Free Software Foundation, either version 3 of the License, or 8 | // (at your option) any later version. 9 | // 10 | // Runway-Examples is distributed in the hope that it will be useful, 11 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | // GNU General Public License for more details. 14 | // 15 | // You should have received a copy of the GNU General Public License 16 | // along with RunwayML. If not, see . 17 | // 18 | // =========================================================================== 19 | 20 | // RUNWAYML 21 | // www.runwayml.com 22 | 23 | // DenseDepth 24 | // Receive HTTP messages from Runway 25 | // Running DenseDepth model 26 | // example by George Profenza 27 | 28 | // import Runway library 29 | import com.runwayml.*; 30 | // reference to runway instance 31 | RunwayHTTP runway; 32 | 33 | PImage runwayResult; 34 | 35 | // status 36 | String status = "Press 'c' to select a content image"; 37 | 38 | // image to send to Runway 39 | PImage contentImage; 40 | 41 | void setup(){ 42 | // match sketch size to default model camera setup 43 | size(1200,400); 44 | // setup Runway 45 | runway = new RunwayHTTP(this); 46 | // update manually 47 | runway.setAutoUpdate(false); 48 | } 49 | 50 | void draw(){ 51 | background(0); 52 | // draw content image (if loaded) 53 | if(contentImage != null){ 54 | image(contentImage,0,0); 55 | } 56 | // draw image received from Runway 57 | if(runwayResult != null){ 58 | image(runwayResult,600,0); 59 | } 60 | // display status 61 | text(status,5,15); 62 | } 63 | 64 | void keyPressed(){ 65 | if(key == 'c'){ 66 | selectInput("Select a content image to process:", "contentImageSelected"); 67 | } 68 | } 69 | 70 | void contentImageSelected(File selection) { 71 | if (selection == null) { 72 | println("Window was closed or the user hit cancel."); 73 | } else { 74 | println("selected " + selection.getAbsolutePath()); 75 | contentImage = loadImage(selection.getAbsolutePath()); 76 | // resize image (adjust as needed) 77 | contentImage.resize(600,400); 78 | // send to Runway 79 | runway.query(contentImage); 80 | } 81 | } 82 | 83 | // this is called when new Runway data is available 84 | void runwayDataEvent(JSONObject runwayData){ 85 | // point the sketch data to the Runway incoming data 86 | String base64ImageString = runwayData.getString("depth_image"); 87 | // try to decode the image from 88 | try{ 89 | runwayResult = ModelUtils.fromBase64(base64ImageString); 90 | }catch(Exception e){ 91 | e.printStackTrace(); 92 | } 93 | status = "received runway result"; 94 | } 95 | 96 | // this is called each time Processing connects to Runway 97 | // Runway sends information about the current model 98 | public void runwayInfoEvent(JSONObject info){ 99 | println(info); 100 | } 101 | // if anything goes wrong 102 | public void runwayErrorEvent(String message){ 103 | println(message); 104 | } 105 | -------------------------------------------------------------------------------- /examples/HTTP/DensePose/DensePose.pde: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2020 RunwayML Examples 2 | // 3 | // This file is part of RunwayML Examples. 4 | // 5 | // Runway-Examples is free software: you can redistribute it and/or modify 6 | // it under the terms of the GNU General Public License as published by 7 | // the Free Software Foundation, either version 3 of the License, or 8 | // (at your option) any later version. 9 | // 10 | // Runway-Examples is distributed in the hope that it will be useful, 11 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | // GNU General Public License for more details. 14 | // 15 | // You should have received a copy of the GNU General Public License 16 | // along with RunwayML. If not, see . 17 | // 18 | // =========================================================================== 19 | 20 | // RUNWAYML 21 | // www.runwayml.com 22 | 23 | // DensePose 24 | // Receive HTTP messages from Runway 25 | // Running DensePose model 26 | // example by George Profenza 27 | 28 | // import video library 29 | import processing.video.*; 30 | 31 | // import Runway library 32 | import com.runwayml.*; 33 | // reference to runway instance 34 | RunwayHTTP runway; 35 | 36 | PImage runwayResult; 37 | 38 | // periocally to be updated using millis() 39 | int lastMillis; 40 | // how often should the above be updated and a time action take place ? 41 | int waitTime = 1000; 42 | 43 | // reference to the camera 44 | Capture camera; 45 | 46 | // status 47 | String status = "waiting ~"+(waitTime/1000)+"s"; 48 | 49 | void setup(){ 50 | // match sketch size to default model camera setup 51 | size(1200,400); 52 | // setup Runway 53 | runway = new RunwayHTTP(this); 54 | // update manually 55 | runway.setAutoUpdate(false); 56 | // setup camera 57 | camera = new Capture(this,640,480); 58 | camera.start(); 59 | // setup timer 60 | lastMillis = millis(); 61 | } 62 | 63 | void draw(){ 64 | background(0); 65 | // update timer 66 | int currentMillis = millis(); 67 | // if the difference between current millis and last time we checked past the wait time 68 | if(currentMillis - lastMillis >= waitTime){ 69 | status = "sending image to Runway"; 70 | // call the timed function 71 | sendFrameToRunway(); 72 | // update lastMillis, preparing for another wait 73 | lastMillis = currentMillis; 74 | } 75 | // draw image received from Runway 76 | if(runwayResult != null){ 77 | image(runwayResult,600,0); 78 | } 79 | // draw camera feed 80 | image(camera,0,0,600,400); 81 | // display status 82 | text(status,5,15); 83 | } 84 | 85 | void sendFrameToRunway(){ 86 | // nothing to send if there's no new camera data available 87 | if(camera.available() == false){ 88 | return; 89 | } 90 | // read a new frame 91 | camera.read(); 92 | // crop image to Runway input format (600x400) 93 | PImage image = camera.get(0,0,600,400); 94 | // query Runway 95 | runway.query(image,ModelUtils.IMAGE_FORMAT_JPG,"input"); 96 | } 97 | 98 | // this is called when new Runway data is available 99 | void runwayDataEvent(JSONObject runwayData){ 100 | // point the sketch data to the Runway incoming data 101 | String base64ImageString = runwayData.getString("output"); 102 | // try to decode the image from 103 | try{ 104 | runwayResult = ModelUtils.fromBase64(base64ImageString); 105 | }catch(Exception e){ 106 | e.printStackTrace(); 107 | } 108 | status = "received runway result"; 109 | } 110 | 111 | // this is called each time Processing connects to Runway 112 | // Runway sends information about the current model 113 | public void runwayInfoEvent(JSONObject info){ 114 | println(info); 115 | } 116 | // if anything goes wrong 117 | public void runwayErrorEvent(String message){ 118 | println(message); 119 | } 120 | -------------------------------------------------------------------------------- /examples/HTTP/DensePoseFileSelect/DensePoseFileSelect.pde: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2020 RunwayML Examples 2 | // 3 | // This file is part of RunwayML Examples. 4 | // 5 | // Runway-Examples is free software: you can redistribute it and/or modify 6 | // it under the terms of the GNU General Public License as published by 7 | // the Free Software Foundation, either version 3 of the License, or 8 | // (at your option) any later version. 9 | // 10 | // Runway-Examples is distributed in the hope that it will be useful, 11 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | // GNU General Public License for more details. 14 | // 15 | // You should have received a copy of the GNU General Public License 16 | // along with RunwayML. If not, see . 17 | // 18 | // =========================================================================== 19 | 20 | // RUNWAYML 21 | // www.runwayml.com 22 | 23 | // Dense Pose 24 | // Receive HTTP messages from Runway 25 | // Running Dense Pose model 26 | // example by George Profenza 27 | 28 | // import Runway library 29 | import com.runwayml.*; 30 | // reference to runway instance 31 | RunwayHTTP runway; 32 | 33 | PImage runwayResult; 34 | PImage contentImage; 35 | // status 36 | String status = "Press 'c' to select a content image"; 37 | 38 | void setup(){ 39 | // match sketch size to default model camera setup 40 | size(600,400); 41 | // setup Runway 42 | runway = new RunwayHTTP(this); 43 | // update manually 44 | runway.setAutoUpdate(false); 45 | } 46 | 47 | void draw(){ 48 | background(0); 49 | // draw content image (if loaded) 50 | if(contentImage != null){ 51 | image(contentImage,0,0); 52 | } 53 | // draw image received from Runway 54 | if(runwayResult != null){ 55 | image(runwayResult,300,0); 56 | } 57 | // display status 58 | text(status,5,15); 59 | } 60 | 61 | void keyPressed(){ 62 | if(key == 'c'){ 63 | selectInput("Select a content image to process:", "contentImageSelected"); 64 | } 65 | } 66 | 67 | void contentImageSelected(File selection) { 68 | if (selection == null) { 69 | println("Window was closed or the user hit cancel."); 70 | } else { 71 | println("selected " + selection.getAbsolutePath()); 72 | contentImage = loadImage(selection.getAbsolutePath()); 73 | // send to Runway 74 | runway.query(contentImage,ModelUtils.IMAGE_FORMAT_JPG,"input"); 75 | } 76 | } 77 | 78 | // this is called when new Runway data is available 79 | void runwayDataEvent(JSONObject runwayData){ 80 | // point the sketch data to the Runway incoming data 81 | String base64ImageString = runwayData.getString("output"); 82 | // try to decode the image from 83 | try{ 84 | runwayResult = ModelUtils.fromBase64(base64ImageString); 85 | }catch(Exception e){ 86 | e.printStackTrace(); 87 | } 88 | status = "received runway result"; 89 | } 90 | 91 | // this is called each time Processing connects to Runway 92 | // Runway sends information about the current model 93 | public void runwayInfoEvent(JSONObject info){ 94 | println(info); 95 | } 96 | // if anything goes wrong 97 | public void runwayErrorEvent(String message){ 98 | println(message); 99 | } 100 | -------------------------------------------------------------------------------- /examples/HTTP/ESRGAN/ESRGAN.pde: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2020 RunwayML Examples 2 | // 3 | // This file is part of RunwayML Examples. 4 | // 5 | // Runway-Examples is free software: you can redistribute it and/or modify 6 | // it under the terms of the GNU General Public License as published by 7 | // the Free Software Foundation, either version 3 of the License, or 8 | // (at your option) any later version. 9 | // 10 | // Runway-Examples is distributed in the hope that it will be useful, 11 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | // GNU General Public License for more details. 14 | // 15 | // You should have received a copy of the GNU General Public License 16 | // along with RunwayML. If not, see . 17 | // 18 | // =========================================================================== 19 | 20 | // RUNWAYML 21 | // www.runwayml.com 22 | 23 | // ESRGAN Demo: 24 | // Receive HTTP messages from Runway 25 | // Running ESRGAN model 26 | // example by George Profenza 27 | // image credits: SuSuMa original source: https://en.wikipedia.org/wiki/White_tiger#/media/File:White-tiger-2407799_1280.jpg 28 | 29 | // import Runway library 30 | import com.runwayml.*; 31 | // reference to runway instance 32 | RunwayHTTP runway; 33 | 34 | PImage inputImage; 35 | PImage outputImage; 36 | 37 | String status = ""; 38 | 39 | void setup() { 40 | size(1024, 512); 41 | noSmooth(); 42 | // setup Runway 43 | runway = new RunwayHTTP(this); 44 | // disable automatic polling: request data manually when a new frame is ready 45 | runway.setAutoUpdate(false); 46 | // load example image: feel free to replace with yours 47 | inputImage = loadImage("white-tiger-128x128.jpg"); 48 | } 49 | 50 | void draw() { 51 | background(0); 52 | // draw input image (if any) 53 | if(outputImage != null){ 54 | image(outputImage,512,0,512,512); 55 | } 56 | // draw webcam image 57 | image(inputImage,0,0,512,512); 58 | // draw instructions 59 | text("press SPACE to send image to Runway\n" + status,5,15); 60 | } 61 | 62 | void keyPressed(){ 63 | if(key == ' '){ 64 | status = "processing data"; 65 | // send inputImage to Runway 66 | runway.query(inputImage); 67 | } 68 | } 69 | 70 | // this is called when new Runway data is available 71 | void runwayDataEvent(JSONObject runwayData){ 72 | // extract Base64 encoded image from JSON object and decode it to a PImage 73 | try{ 74 | outputImage = ModelUtils.fromBase64(runwayData.getString("upscaled")); 75 | status = "processing complete"; 76 | }catch(Exception e){ 77 | println("error parsing runway Data:\n" + runwayData.toString()); 78 | e.printStackTrace(); 79 | } 80 | } 81 | -------------------------------------------------------------------------------- /examples/HTTP/ESRGAN/data/white-tiger-128x128.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/runwayml/processing-library/ee3d79601e3539d68e43979f3b0cf4fe0d812f7c/examples/HTTP/ESRGAN/data/white-tiger-128x128.jpg -------------------------------------------------------------------------------- /examples/HTTP/FaceParser/FaceParser.pde: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2020 RunwayML Examples 2 | // 3 | // This file is part of RunwayML Examples. 4 | // 5 | // Runway-Examples is free software: you can redistribute it and/or modify 6 | // it under the terms of the GNU General Public License as published by 7 | // the Free Software Foundation, either version 3 of the License, or 8 | // (at your option) any later version. 9 | // 10 | // Runway-Examples is distributed in the hope that it will be useful, 11 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | // GNU General Public License for more details. 14 | // 15 | // You should have received a copy of the GNU General Public License 16 | // along with RunwayML. If not, see . 17 | // 18 | // =========================================================================== 19 | 20 | // RUNWAYML 21 | // www.runwayml.com 22 | 23 | // FaceParser 24 | // Receive HTTP messages from Runway 25 | // Running FaceParser model 26 | // example by George Profenza 27 | 28 | // import Runway library 29 | import com.runwayml.*; 30 | // reference to runway instance 31 | RunwayHTTP runway; 32 | 33 | PImage runwayResult; 34 | PImage contentImage; 35 | 36 | // status 37 | String status = "Press 'c' to select a content image"; 38 | 39 | void setup(){ 40 | // match sketch size to default model camera setup 41 | size(1200,400); 42 | // setup Runway 43 | runway = new RunwayHTTP(this); 44 | // update manually 45 | runway.setAutoUpdate(false); 46 | } 47 | 48 | void draw(){ 49 | background(0); 50 | // draw content image (if loaded) 51 | if(contentImage != null){ 52 | image(contentImage,0,0); 53 | } 54 | // draw image received from Runway 55 | if(runwayResult != null){ 56 | image(runwayResult,600,0); 57 | } 58 | // display status 59 | text(status,5,15); 60 | } 61 | 62 | void keyPressed(){ 63 | if(key == 'c'){ 64 | selectInput("Select a content image to process:", "contentImageSelected"); 65 | } 66 | if(key == 's'){ 67 | if(runwayResult != null){ 68 | runwayResult.save(dataPath("result.png")); 69 | } 70 | } 71 | } 72 | 73 | void contentImageSelected(File selection) { 74 | if (selection == null) { 75 | println("Window was closed or the user hit cancel."); 76 | } else { 77 | println("selected " + selection.getAbsolutePath()); 78 | contentImage = loadImage(selection.getAbsolutePath()); 79 | // resize image (adjust as needed) 80 | contentImage.resize(600,400); 81 | // send to Runway 82 | runway.query(contentImage); 83 | } 84 | } 85 | 86 | // this is called when new Runway data is available 87 | void runwayDataEvent(JSONObject runwayData){ 88 | // point the sketch data to the Runway incoming data 89 | String base64ImageString = runwayData.getString("parsed_face"); 90 | // try to decode the image from 91 | try{ 92 | runwayResult = ModelUtils.fromBase64(base64ImageString); 93 | }catch(Exception e){ 94 | e.printStackTrace(); 95 | } 96 | status = "received runway result"; 97 | } 98 | 99 | // this is called each time Processing connects to Runway 100 | // Runway sends information about the current model 101 | public void runwayInfoEvent(JSONObject info){ 102 | println(info); 103 | } 104 | // if anything goes wrong 105 | public void runwayErrorEvent(String message){ 106 | println(message); 107 | } 108 | -------------------------------------------------------------------------------- /examples/HTTP/Face_Recognition_Detect_FileSelect/Face_Recognition_Detect_FileSelect.pde: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2020 RunwayML Examples 2 | // 3 | // This file is part of RunwayML Examples. 4 | // 5 | // Runway-Examples is free software: you can redistribute it and/or modify 6 | // it under the terms of the GNU General Public License as published by 7 | // the Free Software Foundation, either version 3 of the License, or 8 | // (at your option) any later version. 9 | // 10 | // Runway-Examples is distributed in the hope that it will be useful, 11 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | // GNU General Public License for more details. 14 | // 15 | // You should have received a copy of the GNU General Public License 16 | // along with RunwayML. If not, see . 17 | // 18 | // =========================================================================== 19 | 20 | // RUNWAYML 21 | // www.runwayml.com 22 | 23 | // Face Recognition Detect Demo: 24 | // Receive HTTP messages from Runway 25 | // Running Face-Recognition model 26 | 27 | // import video library 28 | import processing.video.*; 29 | // import Runway library 30 | import com.runwayml.*; 31 | // reference to runway instance 32 | RunwayHTTP runway; 33 | 34 | // The data coming in from Runway as a JSON Object {} 35 | JSONObject data; 36 | 37 | PImage inputImage; 38 | 39 | void setup() { 40 | size(600, 400); 41 | frameRate(3); 42 | fill(255); 43 | stroke(255); 44 | // setup Runway 45 | runway = new RunwayHTTP(this); 46 | // disable automatic polling: request data manually when a new frame is ready 47 | runway.setAutoUpdate(false); 48 | } 49 | 50 | void draw() { 51 | background(0); 52 | 53 | // Display label image if loaded 54 | if(inputImage != null){ 55 | image(inputImage,0,0); 56 | } 57 | 58 | // Display instructions 59 | text("press 's' to select an image\npress SPACE to query Runway",5,15); 60 | 61 | // Display captions 62 | drawCaptions(); 63 | } 64 | 65 | void keyPressed(){ 66 | if(key == 's'){ 67 | selectInput("Select an input image to process:", "inputImageSelected"); 68 | } 69 | if(key == ' '){ 70 | if(inputImage != null){ 71 | runway.query(inputImage); 72 | } 73 | } 74 | } 75 | 76 | void inputImageSelected(File selection) { 77 | if (selection == null) { 78 | println("Window was closed or the user hit cancel."); 79 | } else { 80 | println("selected " + selection.getAbsolutePath()); 81 | inputImage = loadImage(selection.getAbsolutePath()); 82 | // resize image (adjust as needed) 83 | inputImage.resize(600,400); 84 | } 85 | } 86 | 87 | // A function to display the captions 88 | void drawCaptions() { 89 | // if no data is loaded yet, exit 90 | if(data == null){ 91 | return; 92 | } 93 | 94 | // access boxes and labels JSON arrays within the result 95 | JSONArray results = data.getJSONArray("results"); 96 | // for each array element 97 | for(int i = 0 ; i < results.size(); i++){ 98 | JSONObject result = results.getJSONObject(i); 99 | 100 | String className = result.getString("class"); 101 | JSONArray box = result.getJSONArray("bbox"); 102 | // extract values from the float array 103 | float x = box.getFloat(0); 104 | float y = box.getFloat(1); 105 | float w = box.getFloat(2); 106 | float h = box.getFloat(3); 107 | // display bounding boxes 108 | noFill(); 109 | rect(x,y,w,h); 110 | fill(255); 111 | text(className,x,y); 112 | } 113 | } 114 | 115 | 116 | 117 | // this is called when new Runway data is available 118 | void runwayDataEvent(JSONObject runwayData){ 119 | // point the sketch data to the Runway incoming data 120 | data = runwayData; 121 | } 122 | -------------------------------------------------------------------------------- /examples/HTTP/FastStyleTransfer/FastStyleTransfer.pde: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2020 RunwayML Examples 2 | // 3 | // This file is part of RunwayML Examples. 4 | // 5 | // Runway-Examples is free software: you can redistribute it and/or modify 6 | // it under the terms of the GNU General Public License as published by 7 | // the Free Software Foundation, either version 3 of the License, or 8 | // (at your option) any later version. 9 | // 10 | // Runway-Examples is distributed in the hope that it will be useful, 11 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | // GNU General Public License for more details. 14 | // 15 | // You should have received a copy of the GNU General Public License 16 | // along with RunwayML. If not, see . 17 | // 18 | // =========================================================================== 19 | 20 | // RUNWAYML 21 | // www.runwayml.com 22 | 23 | // Fast-Style-Transfer 24 | // Receive HTTP messages from Runway 25 | // Running Fast-Style-Transfer model 26 | // example by George Profenza 27 | 28 | // import video library 29 | import processing.video.*; 30 | 31 | // import Runway library 32 | import com.runwayml.*; 33 | // reference to runway instance 34 | RunwayHTTP runway; 35 | 36 | PImage runwayResult; 37 | 38 | // periocally to be updated using millis() 39 | int lastMillis; 40 | // how often should the above be updated and a time action take place ? 41 | int waitTime = 1000; 42 | 43 | // reference to the camera 44 | Capture camera; 45 | 46 | // status 47 | String status = "waiting ~"+(waitTime/1000)+"s"; 48 | 49 | void setup(){ 50 | // match sketch size to default model camera setup 51 | size(1200,400); 52 | // setup Runway 53 | runway = new RunwayHTTP(this); 54 | // update manually 55 | runway.setAutoUpdate(false); 56 | // setup camera 57 | camera = new Capture(this,640,480); 58 | camera.start(); 59 | // setup timer 60 | lastMillis = millis(); 61 | } 62 | 63 | void draw(){ 64 | background(0); 65 | // update timer 66 | int currentMillis = millis(); 67 | // if the difference between current millis and last time we checked past the wait time 68 | if(currentMillis - lastMillis >= waitTime){ 69 | status = "sending image to Runway"; 70 | // call the timed function 71 | sendFrameToRunway(); 72 | // update lastMillis, preparing for another wait 73 | lastMillis = currentMillis; 74 | } 75 | // draw image received from Runway 76 | if(runwayResult != null){ 77 | image(runwayResult,600,0); 78 | } 79 | // draw camera feed 80 | image(camera,0,0,600,400); 81 | // display status 82 | text(status,5,15); 83 | } 84 | 85 | void sendFrameToRunway(){ 86 | // nothing to send if there's no new camera data available 87 | if(camera.available() == false){ 88 | return; 89 | } 90 | // read a new frame 91 | camera.read(); 92 | // crop image to Runway input format (600x400) 93 | PImage image = camera.get(0,0,600,400); 94 | // query Runway 95 | runway.query(image); 96 | } 97 | 98 | // this is called when new Runway data is available 99 | void runwayDataEvent(JSONObject runwayData){ 100 | // point the sketch data to the Runway incoming data 101 | String base64ImageString = runwayData.getString("output"); 102 | // try to decode the image from 103 | try{ 104 | runwayResult = ModelUtils.fromBase64(base64ImageString); 105 | }catch(Exception e){ 106 | e.printStackTrace(); 107 | } 108 | status = "received runway result"; 109 | } 110 | 111 | // this is called each time Processing connects to Runway 112 | // Runway sends information about the current model 113 | public void runwayInfoEvent(JSONObject info){ 114 | println(info); 115 | } 116 | // if anything goes wrong 117 | public void runwayErrorEvent(String message){ 118 | println(message); 119 | } 120 | -------------------------------------------------------------------------------- /examples/HTTP/FastStyleTransferFileSelect/FastStyleTransferFileSelect.pde: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2020 RunwayML Examples 2 | // 3 | // This file is part of RunwayML Examples. 4 | // 5 | // Runway-Examples is free software: you can redistribute it and/or modify 6 | // it under the terms of the GNU General Public License as published by 7 | // the Free Software Foundation, either version 3 of the License, or 8 | // (at your option) any later version. 9 | // 10 | // Runway-Examples is distributed in the hope that it will be useful, 11 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | // GNU General Public License for more details. 14 | // 15 | // You should have received a copy of the GNU General Public License 16 | // along with RunwayML. If not, see . 17 | // 18 | // =========================================================================== 19 | 20 | // RUNWAYML 21 | // www.runwayml.com 22 | 23 | // Fast-Style-Transfer 24 | // Receive HTTP messages from Runway 25 | // Running Fast-Style-Transfer model 26 | // example by George Profenza 27 | 28 | // import Runway library 29 | import com.runwayml.*; 30 | // reference to runway instance 31 | RunwayHTTP runway; 32 | 33 | PImage runwayResult; 34 | PImage contentImage; 35 | // status 36 | String status = "Press 'c' to select a content image"; 37 | 38 | void setup(){ 39 | // match sketch size to default model camera setup 40 | size(1200,400); 41 | // setup Runway 42 | runway = new RunwayHTTP(this); 43 | // update manually 44 | runway.setAutoUpdate(false); 45 | } 46 | 47 | void draw(){ 48 | background(0); 49 | // draw content image (if loaded) 50 | if(contentImage != null){ 51 | image(contentImage,0,0); 52 | } 53 | // draw image received from Runway 54 | if(runwayResult != null){ 55 | image(runwayResult,600,0); 56 | } 57 | // display status 58 | text(status,5,15); 59 | } 60 | 61 | void keyPressed(){ 62 | if(key == 'c'){ 63 | selectInput("Select a content image to process:", "contentImageSelected"); 64 | } 65 | } 66 | 67 | void contentImageSelected(File selection) { 68 | if (selection == null) { 69 | println("Window was closed or the user hit cancel."); 70 | } else { 71 | println("selected " + selection.getAbsolutePath()); 72 | contentImage = loadImage(selection.getAbsolutePath()); 73 | // resize image (adjust as needed) 74 | contentImage.resize(600,400); 75 | // send to Runway 76 | runway.query(contentImage); 77 | } 78 | } 79 | 80 | // this is called when new Runway data is available 81 | void runwayDataEvent(JSONObject runwayData){ 82 | // point the sketch data to the Runway incoming data 83 | String base64ImageString = runwayData.getString("output"); 84 | // try to decode the image from 85 | try{ 86 | runwayResult = ModelUtils.fromBase64(base64ImageString); 87 | }catch(Exception e){ 88 | e.printStackTrace(); 89 | } 90 | status = "received runway result"; 91 | } 92 | 93 | // this is called each time Processing connects to Runway 94 | // Runway sends information about the current model 95 | public void runwayInfoEvent(JSONObject info){ 96 | println(info); 97 | } 98 | // if anything goes wrong 99 | public void runwayErrorEvent(String message){ 100 | println(message); 101 | } 102 | -------------------------------------------------------------------------------- /examples/HTTP/GLOWFileSelect/GLOWFileSelect.pde: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2020 RunwayML Examples 2 | // 3 | // This file is part of RunwayML Examples. 4 | // 5 | // Runway-Examples is free software: you can redistribute it and/or modify 6 | // it under the terms of the GNU General Public License as published by 7 | // the Free Software Foundation, either version 3 of the License, or 8 | // (at your option) any later version. 9 | // 10 | // Runway-Examples is distributed in the hope that it will be useful, 11 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | // GNU General Public License for more details. 14 | // 15 | // You should have received a copy of the GNU General Public License 16 | // along with RunwayML. If not, see . 17 | // 18 | // =========================================================================== 19 | 20 | // RUNWAYML 21 | // www.runwayml.com 22 | 23 | // GLOW Demo: 24 | // Receive HTTP messages from Runway 25 | // Running GLOW model 26 | // example by George Profenza 27 | 28 | int currentFeatureIndex = 2; 29 | String currentFeature = ""; 30 | float amount = 1.0; 31 | 32 | String status = ""; 33 | 34 | // Input Image 35 | PImage inputImage; 36 | 37 | 38 | void setup(){ 39 | size(1200,360); 40 | stroke(255); 41 | 42 | setupRunway(); 43 | 44 | } 45 | 46 | void draw(){ 47 | // clear background 48 | background(0); 49 | // Display image (if loaded) 50 | if(inputImage != null){ 51 | image(inputImage,0,0); 52 | } 53 | // display runway result (if any) 54 | if(runwayResult != null){ 55 | image(runwayResult,600,0); 56 | } 57 | // display usage 58 | text("press 's' to select an input image\npress SPACE to send image to Runway\n"+ 59 | "press LEFT/RIGHT to select feature: " + currentFeature + "\n" + 60 | "drag mouse horizontally to change amount:" + String.format("%.2f",amount),5,15); 61 | // separator 62 | line(600,0,600,360); 63 | } 64 | 65 | 66 | void keyPressed(){ 67 | if(keyCode == LEFT && currentFeatureIndex > 0){ 68 | currentFeatureIndex--; 69 | updateFeature(); 70 | } 71 | if(keyCode == RIGHT && currentFeatureIndex < features.length - 1){ 72 | currentFeatureIndex++; 73 | updateFeature(); 74 | } 75 | if(key == 's'){ 76 | selectInput("Select an input image to process:", "inputImageSelected"); 77 | } 78 | if(key == ' '){ 79 | status = "waiting for results"; 80 | sendImageToRunway(inputImage); 81 | } 82 | } 83 | 84 | void mouseDragged(){ 85 | amount = map(constrain(mouseX,0,width),0,width,0.0,1.0); 86 | } 87 | 88 | void inputImageSelected(File selection) { 89 | if (selection == null) { 90 | println("Window was closed or the user hit cancel."); 91 | } else { 92 | println("selected " + selection.getAbsolutePath()); 93 | inputImage = loadImage(selection.getAbsolutePath()); 94 | } 95 | } 96 | -------------------------------------------------------------------------------- /examples/HTTP/GLOWFileSelect/Runway.pde: -------------------------------------------------------------------------------- 1 | // import Runway library 2 | import com.runwayml.*; 3 | // reference to runway instance 4 | RunwayHTTP runway; 5 | // image from Runway 6 | PImage runwayResult; 7 | 8 | // store just the features 9 | String[] features; 10 | 11 | void setupRunway(){ 12 | // setup Runway 13 | runway = new RunwayHTTP(this); 14 | // disable automatic polling: request data manually when a new frame is ready 15 | runway.setAutoUpdate(false); 16 | } 17 | 18 | void sendImageToRunway(PImage image){ 19 | // prepare the expected input object 20 | JSONObject input = new JSONObject(); 21 | // set image (base64 encoded) 22 | input.setString("image",ModelUtils.toBase64(image)); 23 | // set feature 24 | input.setString("feature",currentFeature); 25 | // set amount 26 | input.setFloat("amount",amount); 27 | // send input to runway 28 | runway.query(input.toString()); 29 | } 30 | 31 | void updateFeature(){ 32 | currentFeature = features[currentFeatureIndex]; 33 | } 34 | 35 | // this is called when new Runway data is available 36 | void runwayDataEvent(JSONObject runwayData){ 37 | // point the sketch data to the Runway incoming data 38 | String base64ImageString = runwayData.getString("output"); 39 | // try to decode the image from 40 | try{ 41 | PImage result = ModelUtils.fromBase64(base64ImageString); 42 | if(result != null){ 43 | runwayResult = result; 44 | status = ""; 45 | } 46 | }catch(Exception e){ 47 | e.printStackTrace(); 48 | } 49 | } 50 | 51 | // this is called each time Processing connects to Runway 52 | // Runway sends information about the current model 53 | public void runwayInfoEvent(JSONObject info){ 54 | // cache the labelToColor data parsed from JSON data to Processing color data 55 | try{ 56 | // access inputs array 57 | JSONArray inputs = info.getJSONArray("inputs"); 58 | // loop through array to find features 59 | for(int i = 0 ; i < inputs.size(); i++){ 60 | // access each input inside the array 61 | JSONObject input = inputs.getJSONObject(i); 62 | // check if the input name is feature 63 | if(input.getString("name").equals("feature")){ 64 | // retrieve the oneOf array which is the array of features: 65 | features = input.getJSONArray("oneOf").getStringArray(); 66 | } 67 | } 68 | // update color to the first label 69 | updateFeature(); 70 | }catch(Exception e){ 71 | println("error parsing SPADE-COCO model info, unexpected JSON data received:\n" + info.format(-1)); 72 | e.printStackTrace(); 73 | } 74 | } 75 | 76 | // if anything goes wrong 77 | public void runwayErrorEvent(String message){ 78 | println(message); 79 | } 80 | -------------------------------------------------------------------------------- /examples/HTTP/GPT2/GPT2.pde: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2020 Runway ML Examples 2 | // 3 | // This file is part of Runway ML Examples. 4 | // 5 | // Runway-Examples is free software: you can redistribute it and/or modify 6 | // it under the terms of the GNU General Public License as published by 7 | // the Free Software Foundation, either version 3 of the License, or 8 | // (at your option) any later version. 9 | // 10 | // Runway-Examples is distributed in the hope that it will be useful, 11 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | // GNU General Public License for more details. 14 | // 15 | // You should have received a copy of the GNU General Public License 16 | // along with Runway. If not, see . 17 | // 18 | // =========================================================================== 19 | 20 | // RUNWAYML 21 | // www.runwayml.com 22 | // original example by https://github.com/maybay21, adapted by George Profenza 23 | 24 | // import controlp5 25 | import controlP5.*; 26 | //create controlP5 instance 27 | ControlP5 cp5; 28 | 29 | // import Runway library 30 | import com.runwayml.*; 31 | // reference to runway instance 32 | RunwayHTTP runway; 33 | 34 | String textValue = ""; 35 | String text_output; 36 | JSONObject data; 37 | JSONObject json_message; 38 | String json_output; 39 | 40 | void setup() { 41 | //create canvas 42 | size(900,700); 43 | 44 | // setup Runway 45 | runway = new RunwayHTTP(this); 46 | // don't send data at the end of each frame automatically 47 | runway.setAutoUpdate(false); 48 | 49 | //create a font 50 | PFont font = createFont("arial",20); 51 | 52 | cp5 = new ControlP5(this); 53 | //definetextField 54 | cp5.addTextfield("input") 55 | .setPosition(20,40) 56 | .setSize(200,40) 57 | .setFont(font) 58 | .setFocus(true) 59 | .setColor(color(0,255,0)) 60 | ; 61 | 62 | 63 | textFont(font); 64 | } 65 | 66 | void draw() { 67 | //create black background 68 | background(0); 69 | fill(255); 70 | 71 | //display the text we are writing to the screen 72 | text(cp5.get(Textfield.class,"input").getText(), 20,180); 73 | 74 | //get the returned results and display them on the interface 75 | text(textValue, 20,80); 76 | if(text_output != null){ 77 | fill(255); 78 | stroke(255); 79 | textSize(12); 80 | text(text_output, 320, 10, 400, height); 81 | } 82 | } 83 | 84 | 85 | //clear the text field after input 86 | void clear() { 87 | cp5.get(Textfield.class,"textValue").clear(); 88 | } 89 | 90 | //send the text from ou interface to RunwayML 91 | void input(String theText) { 92 | //create json object 93 | json_message = new JSONObject(); 94 | 95 | //add the text from the textfield and seed 96 | json_message.setString("prompt", theText); 97 | json_message.setInt("seed", 1); 98 | print(json_message); 99 | json_output = json_message.toString(); 100 | 101 | //send the message to RunwayML 102 | runway.query(json_output); 103 | } 104 | 105 | // this is called when new Runway data is available 106 | void runwayDataEvent(JSONObject runwayData){ 107 | // point the sketch data to the Runway incoming data 108 | data = runwayData; 109 | //get the value of the "text" key 110 | text_output = data.getString("generated_text"); 111 | } 112 | -------------------------------------------------------------------------------- /examples/HTTP/ImageSuperResolution/ImageSuperResolution.pde: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2020 RunwayML Examples 2 | // 3 | // This file is part of RunwayML Examples. 4 | // 5 | // Runway-Examples is free software: you can redistribute it and/or modify 6 | // it under the terms of the GNU General Public License as published by 7 | // the Free Software Foundation, either version 3 of the License, or 8 | // (at your option) any later version. 9 | // 10 | // Runway-Examples is distributed in the hope that it will be useful, 11 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | // GNU General Public License for more details. 14 | // 15 | // You should have received a copy of the GNU General Public License 16 | // along with RunwayML. If not, see . 17 | // 18 | // =========================================================================== 19 | 20 | // RUNWAYML 21 | // www.runwayml.com 22 | 23 | // Image Super Resolution Demo: 24 | // Receive HTTP messages from Runway 25 | // Running Image Super Resolution model 26 | // example by George Profenza 27 | // image credits: SuSuMa original source: https://en.wikipedia.org/wiki/White_tiger#/media/File:White-tiger-2407799_1280.jpg 28 | 29 | // import Runway library 30 | import com.runwayml.*; 31 | // reference to runway instance 32 | RunwayHTTP runway; 33 | 34 | PImage inputImage; 35 | PImage outputImage; 36 | 37 | String status = ""; 38 | 39 | void setup() { 40 | size(1024, 512); 41 | noSmooth(); 42 | // setup Runway 43 | runway = new RunwayHTTP(this); 44 | // disable automatic polling: request data manually when a new frame is ready 45 | runway.setAutoUpdate(false); 46 | // load example image: feel free to replace with yours 47 | inputImage = loadImage("white-tiger-128x128.jpg"); 48 | } 49 | 50 | void draw() { 51 | background(0); 52 | // draw input image (if any) 53 | if(outputImage != null){ 54 | image(outputImage,512,0,512,512); 55 | } 56 | // draw webcam image 57 | image(inputImage,0,0,512,512); 58 | // draw instructions 59 | text("press SPACE to send image to Runway\n" + status,5,15); 60 | } 61 | 62 | void keyPressed(){ 63 | if(key == ' '){ 64 | status = "processing data"; 65 | // send inputImage to Runway 66 | runway.query(inputImage); 67 | } 68 | } 69 | 70 | // this is called when new Runway data is available 71 | void runwayDataEvent(JSONObject runwayData){ 72 | // extract Base64 encoded image from JSON object and decode it to a PImage 73 | try{ 74 | outputImage = ModelUtils.fromBase64(runwayData.getString("upscaled")); 75 | status = "processing complete"; 76 | }catch(Exception e){ 77 | println("error parsing runway Data:\n" + runwayData.toString()); 78 | e.printStackTrace(); 79 | } 80 | } 81 | -------------------------------------------------------------------------------- /examples/HTTP/ImageSuperResolution/data/white-tiger-128x128.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/runwayml/processing-library/ee3d79601e3539d68e43979f3b0cf4fe0d812f7c/examples/HTTP/ImageSuperResolution/data/white-tiger-128x128.jpg -------------------------------------------------------------------------------- /examples/HTTP/MaskRCNNFileSelect/MaskRCNNFileSelect.pde: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2020 RunwayML Examples 2 | // 3 | // This file is part of RunwayML Examples. 4 | // 5 | // Runway-Examples is free software: you can redistribute it and/or modify 6 | // it under the terms of the GNU General Public License as published by 7 | // the Free Software Foundation, either version 3 of the License, or 8 | // (at your option) any later version. 9 | // 10 | // Runway-Examples is distributed in the hope that it will be useful, 11 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | // GNU General Public License for more details. 14 | // 15 | // You should have received a copy of the GNU General Public License 16 | // along with RunwayML. If not, see . 17 | // 18 | // =========================================================================== 19 | 20 | // RUNWAYML 21 | // www.runwayml.com 22 | 23 | // MaskRCNN 24 | // Receive OSC messages from Runway 25 | // Running MaskRCNN model 26 | // example by George Profenza 27 | 28 | // import video library 29 | import processing.video.*; 30 | 31 | // import Runway library 32 | import com.runwayml.*; 33 | // reference to runway instance 34 | RunwayHTTP runway; 35 | 36 | PImage runwayResult; 37 | 38 | // status 39 | String status = ""; 40 | 41 | String category = "person"; 42 | 43 | // Input Image 44 | PImage inputImage; 45 | 46 | void setup(){ 47 | // match sketch size to default model camera setup 48 | size(1200,400); 49 | // setup Runway 50 | runway = new RunwayHTTP(this); 51 | // update manually 52 | runway.setAutoUpdate(false); 53 | } 54 | 55 | void draw(){ 56 | background(0); 57 | // Display image (if loaded) 58 | if(inputImage != null){ 59 | image(inputImage,0,0); 60 | } 61 | 62 | // Display instructions 63 | text("press 's' to select an input image\npress SPACE to query Runway\n"+status,5,15); 64 | // draw image received from Runway 65 | if(runwayResult != null){ 66 | image(runwayResult,600,0); 67 | } 68 | } 69 | 70 | void keyPressed(){ 71 | if(key == 's'){ 72 | selectInput("Select an input image to process:", "inputImageSelected"); 73 | } 74 | if(key == ' '){ 75 | if(inputImage != null){ 76 | runway.query(inputImage); 77 | } 78 | } 79 | } 80 | 81 | void inputImageSelected(File selection) { 82 | if (selection == null) { 83 | println("Window was closed or the user hit cancel."); 84 | } else { 85 | println("selected " + selection.getAbsolutePath()); 86 | inputImage = loadImage(selection.getAbsolutePath()); 87 | } 88 | } 89 | 90 | void queryRunway(){ 91 | // nothing to do if there's no input image 92 | if(inputImage == null){ 93 | return; 94 | } 95 | // create input JSON object to hold image and category data 96 | JSONObject input = new JSONObject(); 97 | // set image 98 | input.setString("image",ModelUtils.toBase64(inputImage)); 99 | // set category 100 | input.setString("category",category); 101 | // query Runway 102 | runway.query(input.toString()); 103 | } 104 | 105 | 106 | // this is called when new Runway data is available 107 | void runwayDataEvent(JSONObject runwayData){ 108 | // point the sketch data to the Runway incoming data 109 | String base64ImageString = runwayData.getString("output"); 110 | // try to decode the image from 111 | try{ 112 | runwayResult = ModelUtils.fromBase64(base64ImageString); 113 | }catch(Exception e){ 114 | e.printStackTrace(); 115 | } 116 | status = "received runway result"; 117 | } 118 | 119 | // this is called each time Processing connects to Runway 120 | // Runway sends information about the current model 121 | public void runwayInfoEvent(JSONObject info){ 122 | println(info); 123 | } 124 | // if anything goes wrong 125 | public void runwayErrorEvent(String message){ 126 | println(message); 127 | } 128 | -------------------------------------------------------------------------------- /examples/HTTP/MobileNetFileSelect/MobileNetFileSelect.pde: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2020 RunwayML Examples 2 | // 3 | // This file is part of RunwayML Examples. 4 | // 5 | // Runway-Examples is free software: you can redistribute it and/or modify 6 | // it under the terms of the GNU General Public License as published by 7 | // the Free Software Foundation, either version 3 of the License, or 8 | // (at your option) any later version. 9 | // 10 | // Runway-Examples is distributed in the hope that it will be useful, 11 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | // GNU General Public License for more details. 14 | // 15 | // You should have received a copy of the GNU General Public License 16 | // along with RunwayML. If not, see . 17 | // 18 | // =========================================================================== 19 | 20 | // RUNWAYML 21 | // www.runwayml.com 22 | 23 | // MobileNet Demo: 24 | // Receive HTTP messages from Runway 25 | // Running MobileNet model 26 | // Example by George Profenza 27 | 28 | // import Runway library 29 | import com.runwayml.*; 30 | // reference to runway instance 31 | RunwayHTTP runway; 32 | 33 | // The data coming in from Runway as a JSON Object {} 34 | JSONObject data; 35 | 36 | // status 37 | String status = "Press 'c' to select a content image"; 38 | 39 | // image to send to Runway 40 | PImage contentImage; 41 | 42 | void setup() { 43 | size(600, 400); 44 | frameRate(3); 45 | fill(255); 46 | stroke(255); 47 | // setup Runway 48 | runway = new RunwayHTTP(this); 49 | // disable automatic polling: request data manually when a new frame is ready 50 | runway.setAutoUpdate(false); 51 | } 52 | 53 | void draw() { 54 | background(0); 55 | // draw content image (if loaded) 56 | if(contentImage != null){ 57 | image(contentImage,0,0); 58 | } 59 | 60 | // Display captions 61 | drawCaptions(); 62 | 63 | // display status 64 | text(status,5,15); 65 | } 66 | 67 | 68 | void keyPressed(){ 69 | if(key == 'c'){ 70 | selectInput("Select a content image to process:", "contentImageSelected"); 71 | } 72 | } 73 | 74 | void contentImageSelected(File selection) { 75 | if (selection == null) { 76 | println("Window was closed or the user hit cancel."); 77 | } else { 78 | println("selected " + selection.getAbsolutePath()); 79 | contentImage = loadImage(selection.getAbsolutePath()); 80 | // resize image (adjust as needed) 81 | contentImage.resize(600,400); 82 | // send to Runway 83 | runway.query(contentImage); 84 | } 85 | } 86 | 87 | 88 | // A function to display the captions 89 | void drawCaptions() { 90 | // if no data is loaded yet, exit 91 | if(data == null){ 92 | return; 93 | } 94 | println(data); 95 | noStroke(); 96 | fill(0); 97 | rect(0,0,210,120); 98 | // access boxes and labels JSON arrays within the result 99 | JSONArray results = data.getJSONArray("results"); 100 | // for each array element 101 | for(int i = 0 ; i < results.size(); i++){ 102 | JSONObject result = results.getJSONObject(i); 103 | String className = result.getString("className"); 104 | float probability = result.getFloat("probability"); 105 | fill(255); 106 | text("className: " + className + "\nprobability: " + String.format("%.2f",probability),5,30 * (i+1)); 107 | } 108 | } 109 | 110 | // this is called when new Runway data is available 111 | void runwayDataEvent(JSONObject runwayData){ 112 | // point the sketch data to the Runway incoming data 113 | data = runwayData; 114 | } 115 | -------------------------------------------------------------------------------- /examples/HTTP/OpenGPT2/OpenGPT2.pde: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2020 Runway ML Examples 2 | // 3 | // This file is part of Runway ML Examples. 4 | // 5 | // Runway-Examples is free software: you can redistribute it and/or modify 6 | // it under the terms of the GNU General Public License as published by 7 | // the Free Software Foundation, either version 3 of the License, or 8 | // (at your option) any later version. 9 | // 10 | // Runway-Examples is distributed in the hope that it will be useful, 11 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | // GNU General Public License for more details. 14 | // 15 | // You should have received a copy of the GNU General Public License 16 | // along with Runway. If not, see . 17 | // 18 | // =========================================================================== 19 | 20 | // RUNWAYML 21 | // www.runwayml.com 22 | // original example by https://github.com/maybay21, adapted by George Profenza 23 | 24 | // import controlp5 25 | import controlP5.*; 26 | //create controlP5 instance 27 | ControlP5 cp5; 28 | 29 | // import Runway library 30 | import com.runwayml.*; 31 | // reference to runway instance 32 | RunwayHTTP runway; 33 | 34 | String textValue = ""; 35 | String text_output; 36 | JSONObject data; 37 | JSONObject json_message; 38 | String json_output; 39 | 40 | void setup() { 41 | //create canvas 42 | size(900,700); 43 | 44 | // setup Runway 45 | runway = new RunwayHTTP(this); 46 | // don't send data at the end of each frame automatically 47 | runway.setAutoUpdate(false); 48 | 49 | //create a font 50 | PFont font = createFont("arial",20); 51 | 52 | cp5 = new ControlP5(this); 53 | //definetextField 54 | cp5.addTextfield("input") 55 | .setPosition(20,40) 56 | .setSize(200,40) 57 | .setFont(font) 58 | .setFocus(true) 59 | .setColor(color(0,255,0)) 60 | ; 61 | 62 | 63 | textFont(font); 64 | } 65 | 66 | void draw() { 67 | //create black background 68 | background(0); 69 | fill(255); 70 | 71 | //display the text we are writing to the screen 72 | text(cp5.get(Textfield.class,"input").getText(), 20,180); 73 | 74 | //get the returned results and display them on the interface 75 | text(textValue, 20,80); 76 | if(text_output != null){ 77 | fill(255); 78 | stroke(255); 79 | textSize(12); 80 | text(text_output, 320, 10, 400, height); 81 | } 82 | } 83 | 84 | 85 | //clear the text field after input 86 | void clear() { 87 | cp5.get(Textfield.class,"textValue").clear(); 88 | } 89 | 90 | //send the text from ou interface to RunwayML 91 | void input(String theText) { 92 | //create json object 93 | json_message = new JSONObject(); 94 | 95 | //add the text from the textfield and seed 96 | json_message.setString("prompt", theText); 97 | print(json_message); 98 | json_output = json_message.toString(); 99 | 100 | //send the message to RunwayML 101 | runway.query(json_output); 102 | } 103 | 104 | // this is called when new Runway data is available 105 | void runwayDataEvent(JSONObject runwayData){ 106 | // point the sketch data to the Runway incoming data 107 | data = runwayData; 108 | //get the value of the "text" key 109 | text_output = data.getString("generated_text"); 110 | } 111 | -------------------------------------------------------------------------------- /examples/HTTP/PhotoSketch/PhotoSketch.pde: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2020 RunwayML Examples 2 | // 3 | // This file is part of RunwayML Examples. 4 | // 5 | // Runway-Examples is free software: you can redistribute it and/or modify 6 | // it under the terms of the GNU General Public License as published by 7 | // the Free Software Foundation, either version 3 of the License, or 8 | // (at your option) any later version. 9 | // 10 | // Runway-Examples is distributed in the hope that it will be useful, 11 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | // GNU General Public License for more details. 14 | // 15 | // You should have received a copy of the GNU General Public License 16 | // along with RunwayML. If not, see . 17 | // 18 | // =========================================================================== 19 | 20 | // RUNWAYML 21 | // www.runwayml.com 22 | 23 | // PhotoSketch 24 | // Receive HTTP messages from Runway 25 | // Running PhotoSketch model 26 | // example by George Profenza 27 | 28 | // import video library 29 | import processing.video.*; 30 | 31 | // import Runway library 32 | import com.runwayml.*; 33 | // reference to runway instance 34 | RunwayHTTP runway; 35 | 36 | PImage runwayResult; 37 | 38 | // periocally to be updated using millis() 39 | int lastMillis; 40 | // how often should the above be updated and a time action take place ? 41 | int waitTime = 1000; 42 | 43 | // reference to the camera 44 | Capture camera; 45 | 46 | // status 47 | String status = "waiting ~"+(waitTime/1000)+"s"; 48 | 49 | String category = "person"; 50 | 51 | void setup(){ 52 | // match sketch size to default model camera setup 53 | size(1200,400); 54 | // setup Runway 55 | runway = new RunwayHTTP(this); 56 | // update manually 57 | runway.setAutoUpdate(false); 58 | // setup camera 59 | camera = new Capture(this,640,480); 60 | camera.start(); 61 | // setup timer 62 | lastMillis = millis(); 63 | } 64 | 65 | void draw(){ 66 | background(0); 67 | // update timer 68 | int currentMillis = millis(); 69 | // if the difference between current millis and last time we checked past the wait time 70 | if(currentMillis - lastMillis >= waitTime){ 71 | status = "sending image to Runway"; 72 | // call the timed function 73 | sendFrameToRunway(); 74 | // update lastMillis, preparing for another wait 75 | lastMillis = currentMillis; 76 | } 77 | // draw image received from Runway 78 | if(runwayResult != null){ 79 | image(runwayResult,600,0); 80 | } 81 | // draw camera feed 82 | image(camera,0,0,600,400); 83 | // display status 84 | text(status,5,15); 85 | } 86 | 87 | void sendFrameToRunway(){ 88 | // nothing to send if there's no new camera data available 89 | if(camera.available() == false){ 90 | return; 91 | } 92 | // read a new frame 93 | camera.read(); 94 | // crop image to Runway input format (600x400) 95 | PImage image = camera.get(0,0,600,400); 96 | // query Runway 97 | runway.query(image,ModelUtils.IMAGE_FORMAT_JPG,"input"); 98 | } 99 | 100 | 101 | // this is called when new Runway data is available 102 | void runwayDataEvent(JSONObject runwayData){ 103 | // point the sketch data to the Runway incoming data 104 | String base64ImageString = runwayData.getString("output"); 105 | // try to decode the image from 106 | try{ 107 | runwayResult = ModelUtils.fromBase64(base64ImageString); 108 | }catch(Exception e){ 109 | e.printStackTrace(); 110 | } 111 | status = "received runway result"; 112 | } 113 | 114 | // this is called each time Processing connects to Runway 115 | // Runway sends information about the current model 116 | public void runwayInfoEvent(JSONObject info){ 117 | println(info); 118 | } 119 | // if anything goes wrong 120 | public void runwayErrorEvent(String message){ 121 | println(message); 122 | } 123 | -------------------------------------------------------------------------------- /examples/HTTP/Pix2PixFileSelect/Pix2PixFileSelect.pde: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2020 RunwayML Examples 2 | // 3 | // This file is part of RunwayML Examples. 4 | // 5 | // Runway-Examples is free software: you can redistribute it and/or modify 6 | // it under the terms of the GNU General Public License as published by 7 | // the Free Software Foundation, either version 3 of the License, or 8 | // (at your option) any later version. 9 | // 10 | // Runway-Examples is distributed in the hope that it will be useful, 11 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | // GNU General Public License for more details. 14 | // 15 | // You should have received a copy of the GNU General Public License 16 | // along with RunwayML. If not, see . 17 | // 18 | // =========================================================================== 19 | 20 | // RUNWAYML 21 | // www.runwayml.com 22 | 23 | // Pix2Pix 24 | // Receive HTTP messages from Runway 25 | // Running Pix2Pix model 26 | // example by George Profenza 27 | 28 | // import Runway library 29 | import com.runwayml.*; 30 | // reference to runway instance 31 | RunwayHTTP runway; 32 | 33 | PImage runwayResult; 34 | PImage contentImage; 35 | 36 | // status 37 | String status = "Press 'c' to select a content image"; 38 | 39 | void setup(){ 40 | // match sketch size to default model camera setup 41 | size(1200,600); 42 | // setup Runway 43 | runway = new RunwayHTTP(this); 44 | // update manually 45 | runway.setAutoUpdate(false); 46 | } 47 | 48 | void draw(){ 49 | background(0); 50 | // draw content image (if loaded) 51 | if(contentImage != null){ 52 | image(contentImage,0,0); 53 | } 54 | // draw image received from Runway 55 | if(runwayResult != null){ 56 | image(runwayResult,600,0); 57 | } 58 | // display status 59 | text(status,5,15); 60 | } 61 | 62 | void keyPressed(){ 63 | if(key == 'c'){ 64 | selectInput("Select a content image to process:", "contentImageSelected"); 65 | } 66 | if(key == 's'){ 67 | if(runwayResult != null){ 68 | runwayResult.save(dataPath("result.png")); 69 | } 70 | } 71 | } 72 | 73 | void contentImageSelected(File selection) { 74 | if (selection == null) { 75 | println("Window was closed or the user hit cancel."); 76 | } else { 77 | println("selected " + selection.getAbsolutePath()); 78 | contentImage = loadImage(selection.getAbsolutePath()); 79 | // send to Runway 80 | runway.query(contentImage); 81 | } 82 | } 83 | 84 | // this is called when new Runway data is available 85 | void runwayDataEvent(JSONObject runwayData){ 86 | // point the sketch data to the Runway incoming data 87 | String base64ImageString = runwayData.getString("image"); 88 | // try to decode the image from 89 | try{ 90 | runwayResult = ModelUtils.fromBase64(base64ImageString); 91 | }catch(Exception e){ 92 | e.printStackTrace(); 93 | } 94 | status = "received runway result"; 95 | } 96 | 97 | // this is called each time Processing connects to Runway 98 | // Runway sends information about the current model 99 | public void runwayInfoEvent(JSONObject info){ 100 | println(info); 101 | } 102 | // if anything goes wrong 103 | public void runwayErrorEvent(String message){ 104 | println(message); 105 | } 106 | -------------------------------------------------------------------------------- /examples/HTTP/Places365FileSelect/Places365FileSelect.pde: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2020 RunwayML Examples 2 | // 3 | // This file is part of RunwayML Examples. 4 | // 5 | // Runway-Examples is free software: you can redistribute it and/or modify 6 | // it under the terms of the GNU General Public License as published by 7 | // the Free Software Foundation, either version 3 of the License, or 8 | // (at your option) any later version. 9 | // 10 | // Runway-Examples is distributed in the hope that it will be useful, 11 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | // GNU General Public License for more details. 14 | // 15 | // You should have received a copy of the GNU General Public License 16 | // along with RunwayML. If not, see . 17 | // 18 | // =========================================================================== 19 | 20 | // RUNWAYML 21 | // www.runwayml.com 22 | 23 | // Places365 Demo: 24 | // Receive HTTP messages from Runway 25 | // Running Places365 model 26 | // Original example by Cris Valenzuela, Anastasis Germanidis, Gene Kogan, adapted by George Profenza 27 | 28 | // import Runway library 29 | import com.runwayml.*; 30 | // reference to runway instance 31 | RunwayHTTP runway; 32 | 33 | // The data coming in from Runway as a JSON Object {} 34 | JSONObject data; 35 | 36 | // Input Image 37 | PImage inputImage; 38 | 39 | void setup() { 40 | size(500, 300); 41 | fill(255); 42 | stroke(255); 43 | // setup Runway 44 | runway = new RunwayHTTP(this); 45 | // disable auto updates 46 | runway.setAutoUpdate(false); 47 | } 48 | 49 | void draw() { 50 | background(0); 51 | 52 | // Display image (if loaded) 53 | if(inputImage != null){ 54 | image(inputImage,0,0); 55 | } 56 | 57 | // Display instructions 58 | text("press 's' to select an input image\npress SPACE to query Runway",5,15); 59 | 60 | // Display captions 61 | drawCaptions(); 62 | } 63 | 64 | 65 | // A function to display the captions 66 | void drawCaptions() { 67 | // Only if there are any captions 68 | if (data != null) { 69 | String results = data.getString("label"); 70 | text(results, 100, 100); 71 | } 72 | } 73 | 74 | void keyPressed(){ 75 | if(key == 's'){ 76 | selectInput("Select an input image to process:", "inputImageSelected"); 77 | } 78 | if(key == ' '){ 79 | if(inputImage != null){ 80 | runway.query(inputImage,ModelUtils.IMAGE_FORMAT_JPG,"photo"); 81 | } 82 | } 83 | } 84 | 85 | void inputImageSelected(File selection) { 86 | if (selection == null) { 87 | println("Window was closed or the user hit cancel."); 88 | } else { 89 | println("selected " + selection.getAbsolutePath()); 90 | inputImage = loadImage(selection.getAbsolutePath()); 91 | } 92 | } 93 | 94 | // this is called when new Runway data is available 95 | void runwayDataEvent(JSONObject runwayData){ 96 | // point the sketch data to the Runway incoming data 97 | data = runwayData; 98 | } 99 | -------------------------------------------------------------------------------- /examples/HTTP/PoseNetBasics/PoseNetBasics.pde: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2020 RunwayML Examples 2 | // 3 | // This file is part of RunwayML Examples. 4 | // 5 | // Runway-Examples is free software: you can redistribute it and/or modify 6 | // it under the terms of the GNU General Public License as published by 7 | // the Free Software Foundation, either version 3 of the License, or 8 | // (at your option) any later version. 9 | // 10 | // Runway-Examples is distributed in the hope that it will be useful, 11 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | // GNU General Public License for more details. 14 | // 15 | // You should have received a copy of the GNU General Public License 16 | // along with RunwayML. If not, see . 17 | // 18 | // =========================================================================== 19 | 20 | // RUNWAYML 21 | // www.runwayml.com 22 | 23 | // PoseNet Demo: 24 | // Receive OSC messages from Runway 25 | // Running PoseNet model 26 | // original example by Anastasis Germanidis, adapted by George Profenza 27 | 28 | // import Runway library 29 | import com.runwayml.*; 30 | // reference to runway instance 31 | RunwayHTTP runway; 32 | 33 | // This array will hold all the humans detected 34 | JSONObject data; 35 | 36 | void setup(){ 37 | // match sketch size to default model camera setup 38 | size(600,400); 39 | // setup Runway 40 | runway = new RunwayHTTP(this); 41 | } 42 | 43 | void draw(){ 44 | background(0); 45 | // use the utiliy class to draw PoseNet parts 46 | ModelUtils.drawPoseParts(data,g,10); 47 | } 48 | 49 | // this is called when new Runway data is available 50 | void runwayDataEvent(JSONObject runwayData){ 51 | // point the sketch data to the Runway incoming data 52 | data = runwayData; 53 | } 54 | -------------------------------------------------------------------------------- /examples/HTTP/SPADE_COCO_FileSelect/Runway.pde: -------------------------------------------------------------------------------- 1 | // import Runway library 2 | import com.runwayml.*; 3 | // reference to runway instance 4 | RunwayHTTP runway; 5 | // image from Runway 6 | PImage runwayResult; 7 | 8 | // For this example we only care about label to RGB values associations 9 | HashMap labelToColor = new HashMap(); 10 | // store just the SPADE-COCO labels 11 | String[] labels; 12 | 13 | void setupRunway(){ 14 | // setup Runway 15 | runway = new RunwayHTTP(this); 16 | // disable automatic polling: request data manually when a new frame is ready 17 | runway.setAutoUpdate(false); 18 | } 19 | 20 | void sendImageToRunway(PImage image){ 21 | runway.query(image,ModelUtils.IMAGE_FORMAT_PNG,"semantic_map"); 22 | } 23 | 24 | void updateLabelColor(){ 25 | currentLabelColor = labelToColor.get(labels[currentLabelIndex]); 26 | } 27 | 28 | // this is called when new Runway data is available 29 | void runwayDataEvent(JSONObject runwayData){ 30 | // point the sketch data to the Runway incoming data 31 | String base64ImageString = runwayData.getString("output"); 32 | // try to decode the image from 33 | try{ 34 | PImage result = ModelUtils.fromBase64(base64ImageString); 35 | if(result != null){ 36 | runwayResult = result; 37 | status = ""; 38 | } 39 | }catch(Exception e){ 40 | e.printStackTrace(); 41 | } 42 | } 43 | 44 | // this is called each time Processing connects to Runway 45 | // Runway sends information about the current model 46 | public void runwayInfoEvent(JSONObject info){ 47 | // cache the labelToColor data parsed from JSON data to Processing color data 48 | try{ 49 | // access labelToColor object inside the first element of the "inputs" value 50 | JSONObject firstInput = info.getJSONArray("inputs").getJSONObject(0); 51 | //access labelToColor object within the first input 52 | JSONObject labelToColorJSON = firstInput.getJSONObject("labelToColor"); 53 | // access labelToColor object within the first input 54 | JSONObject labelToId = firstInput.getJSONObject("labelToId"); 55 | // allocate labels array 56 | labels = new String[labelToId.size()]; 57 | println(labels.length); 58 | // iterate through each key in the JSON object 59 | for(Object labelObj : labelToColorJSON.keys()){ 60 | // cast the key from Object to String 61 | String label = (String)labelObj; 62 | // parse integer values from the JSON Array values 63 | int[] rgbValues = labelToColorJSON.getJSONArray(label).getIntArray(); 64 | // populate the labelToColour lookup table / hashmap 65 | labelToColor.put(label,color(rgbValues[0],rgbValues[1],rgbValues[2])); 66 | // populate the labels array 67 | int id = labelToId.getInt(label); 68 | labels[id] = label; 69 | } 70 | // update color to the first label 71 | updateLabelColor(); 72 | }catch(Exception e){ 73 | println("error parsing SPADE-COCO model info, unexpected JSON data received:\n" + info.toString()); 74 | e.printStackTrace(); 75 | } 76 | } 77 | 78 | // if anything goes wrong 79 | public void runwayErrorEvent(String message){ 80 | println(message); 81 | } 82 | -------------------------------------------------------------------------------- /examples/HTTP/SPADE_COCO_FileSelect/SPADE_COCO_FileSelect.pde: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2020 RunwayML Examples 2 | // 3 | // This file is part of RunwayML Examples. 4 | // 5 | // Runway-Examples is free software: you can redistribute it and/or modify 6 | // it under the terms of the GNU General Public License as published by 7 | // the Free Software Foundation, either version 3 of the License, or 8 | // (at your option) any later version. 9 | // 10 | // Runway-Examples is distributed in the hope that it will be useful, 11 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | // GNU General Public License for more details. 14 | // 15 | // You should have received a copy of the GNU General Public License 16 | // along with RunwayML. If not, see . 17 | // 18 | // =========================================================================== 19 | 20 | // RUNWAYML 21 | // www.runwayml.com 22 | 23 | // SPADE COCO Demo: 24 | // Receive HTTP messages from Runway 25 | // Running SPADE COCO model 26 | // example by George Profenza 27 | 28 | // drawing layer 29 | int currentLabelIndex = 0; 30 | int currentLabelColor; 31 | 32 | String status = ""; 33 | 34 | // Input Image 35 | PImage inputImage; 36 | 37 | void setup(){ 38 | size(1280,360); 39 | stroke(255); 40 | 41 | setupRunway(); 42 | 43 | } 44 | 45 | void draw(){ 46 | // clear background 47 | background(0); 48 | // Display image (if loaded) 49 | if(inputImage != null){ 50 | image(inputImage,0,0); 51 | } 52 | // display runway result (if any) 53 | if(runwayResult != null){ 54 | image(runwayResult,640,0); 55 | } 56 | // display usage 57 | if(labels != null){ 58 | text("press 's' to select an input image\npress SPACE to send image to Runway",5,15); 59 | } 60 | // separator 61 | line(640,0,640,360); 62 | } 63 | 64 | void keyPressed(){ 65 | if(key == 's'){ 66 | selectInput("Select an input image to process:", "inputImageSelected"); 67 | } 68 | if(key == ' '){ 69 | status = "waiting for results"; 70 | sendImageToRunway(inputImage); 71 | } 72 | } 73 | 74 | void inputImageSelected(File selection) { 75 | if (selection == null) { 76 | println("Window was closed or the user hit cancel."); 77 | } else { 78 | println("selected " + selection.getAbsolutePath()); 79 | inputImage = loadImage(selection.getAbsolutePath()); 80 | } 81 | } 82 | -------------------------------------------------------------------------------- /examples/HTTP/SPADE_COCO_Paint/Runway.pde: -------------------------------------------------------------------------------- 1 | // import Runway library 2 | import com.runwayml.*; 3 | // reference to runway instance 4 | RunwayHTTP runway; 5 | // image from Runway 6 | PImage runwayResult; 7 | 8 | // For this example we only care about label to RGB values associations 9 | HashMap labelToColor = new HashMap(); 10 | // store just the SPADE-COCO labels 11 | String[] labels; 12 | 13 | void setupRunway(){ 14 | // setup Runway 15 | runway = new RunwayHTTP(this); 16 | // disable automatic polling: request data manually when a new frame is ready 17 | runway.setAutoUpdate(false); 18 | } 19 | 20 | void sendImageToRunway(){ 21 | runway.query(drawing.get(),ModelUtils.IMAGE_FORMAT_PNG,"semantic_map"); 22 | } 23 | 24 | void updateLabelColor(){ 25 | currentLabelColor = labelToColor.get(labels[currentLabelIndex]); 26 | } 27 | 28 | // this is called when new Runway data is available 29 | void runwayDataEvent(JSONObject runwayData){ 30 | // point the sketch data to the Runway incoming data 31 | String base64ImageString = runwayData.getString("output"); 32 | // try to decode the image from 33 | try{ 34 | PImage result = ModelUtils.fromBase64(base64ImageString); 35 | if(result != null){ 36 | runwayResult = result; 37 | status = ""; 38 | } 39 | }catch(Exception e){ 40 | e.printStackTrace(); 41 | } 42 | } 43 | 44 | // this is called each time Processing connects to Runway 45 | // Runway sends information about the current model 46 | public void runwayInfoEvent(JSONObject info){ 47 | // cache the labelToColor data parsed from JSON data to Processing color data 48 | try{ 49 | // access labelToColor object inside the first element of the "inputs" value 50 | JSONObject firstInput = info.getJSONArray("inputs").getJSONObject(0); 51 | //access labelToColor object within the first input 52 | JSONObject labelToColorJSON = firstInput.getJSONObject("labelToColor"); 53 | // access labelToColor object within the first input 54 | JSONObject labelToId = firstInput.getJSONObject("labelToId"); 55 | // allocate labels array 56 | labels = new String[labelToId.size()]; 57 | println(labels.length); 58 | // iterate through each key in the JSON object 59 | for(Object labelObj : labelToColorJSON.keys()){ 60 | // cast the key from Object to String 61 | String label = (String)labelObj; 62 | // parse integer values from the JSON Array values 63 | int[] rgbValues = labelToColorJSON.getJSONArray(label).getIntArray(); 64 | // populate the labelToColour lookup table / hashmap 65 | labelToColor.put(label,color(rgbValues[0],rgbValues[1],rgbValues[2])); 66 | // populate the labels array 67 | int id = labelToId.getInt(label); 68 | labels[id] = label; 69 | } 70 | // update color to the first label 71 | updateLabelColor(); 72 | }catch(Exception e){ 73 | println("error parsing SPADE-COCO model info, unexpected JSON data received:\n" + info.toString()); 74 | e.printStackTrace(); 75 | } 76 | } 77 | 78 | // if anything goes wrong 79 | public void runwayErrorEvent(String message){ 80 | println(message); 81 | } 82 | -------------------------------------------------------------------------------- /examples/HTTP/SPADE_COCO_Paint/SPADE_COCO_Paint.pde: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2020 RunwayML Examples 2 | // 3 | // This file is part of RunwayML Examples. 4 | // 5 | // Runway-Examples is free software: you can redistribute it and/or modify 6 | // it under the terms of the GNU General Public License as published by 7 | // the Free Software Foundation, either version 3 of the License, or 8 | // (at your option) any later version. 9 | // 10 | // Runway-Examples is distributed in the hope that it will be useful, 11 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | // GNU General Public License for more details. 14 | // 15 | // You should have received a copy of the GNU General Public License 16 | // along with RunwayML. If not, see . 17 | // 18 | // =========================================================================== 19 | 20 | // RUNWAYML 21 | // www.runwayml.com 22 | 23 | // SPADE COCO Demo: 24 | // Receive HTTP messages from Runway 25 | // Running SPADE COCO model 26 | // example by George Profenza 27 | 28 | // drawing layer 29 | PGraphics drawing; 30 | int currentLabelIndex = 0; 31 | int currentLabelColor; 32 | 33 | String status = ""; 34 | 35 | void setup(){ 36 | size(1280,360); 37 | stroke(255); 38 | 39 | setupRunway(); 40 | 41 | //setup drawing layer 42 | drawing = createGraphics(640,360); 43 | drawing.beginDraw(); 44 | drawing.background(0); 45 | drawing.noStroke(); 46 | drawing.endDraw(); 47 | } 48 | 49 | void draw(){ 50 | // clear background 51 | background(0); 52 | // preview drawing 53 | image(drawing,0,0); 54 | // display runway result (if any) 55 | if(runwayResult != null){ 56 | image(runwayResult,640,0); 57 | } 58 | // display usage 59 | if(labels != null){ 60 | text("LEFT/RIGHT = cycle through labels\n" + 61 | "currentLabel: " + labels[currentLabelIndex] + "\n" + 62 | "click to draw\npress SPACE to send image to Runway\n" + status,5,15); 63 | } 64 | // separator 65 | line(640,0,640,360); 66 | } 67 | 68 | void mouseDragged(){ 69 | drawing.beginDraw(); 70 | drawing.fill(currentLabelColor); 71 | drawing.ellipse(constrain(mouseX,0,640),constrain(mouseY,0,360),21,21); 72 | drawing.endDraw(); 73 | } 74 | 75 | void keyPressed(){ 76 | if(keyCode == LEFT && currentLabelIndex > 0){ 77 | currentLabelIndex--; 78 | updateLabelColor(); 79 | } 80 | if(keyCode == RIGHT && currentLabelIndex < labels.length - 1){ 81 | currentLabelIndex++; 82 | updateLabelColor(); 83 | } 84 | if(key == ' '){ 85 | status = "waiting for results"; 86 | sendImageToRunway(); 87 | } 88 | } 89 | -------------------------------------------------------------------------------- /examples/HTTP/SPADE_Landscapes_FileSelect/Runway.pde: -------------------------------------------------------------------------------- 1 | // import Runway library 2 | import com.runwayml.*; 3 | // reference to runway instance 4 | RunwayHTTP runway; 5 | // image from Runway 6 | PImage runwayResult; 7 | 8 | // For this example we only care about label to RGB values associations 9 | HashMap labelToColor = new HashMap(); 10 | HashMap labelToId = new HashMap(); 11 | // store just the SPADE-COCO labels 12 | String[] labels; 13 | 14 | void setupRunway(){ 15 | // setup Runway 16 | runway = new RunwayHTTP(this); 17 | // disable automatic polling: request data manually when a new frame is ready 18 | runway.setAutoUpdate(false); 19 | } 20 | 21 | void sendImageToRunway(PImage image){ 22 | runway.query(image,ModelUtils.IMAGE_FORMAT_PNG,"semantic_map"); 23 | } 24 | 25 | void updateLabelColor(){ 26 | currentLabelColor = labelToColor.get(labels[currentLabelIndex]); 27 | } 28 | 29 | // this is called when new Runway data is available 30 | void runwayDataEvent(JSONObject runwayData){ 31 | // point the sketch data to the Runway incoming data 32 | String base64ImageString = runwayData.getString("output"); 33 | // try to decode the image from 34 | try{ 35 | PImage result = ModelUtils.fromBase64(base64ImageString); 36 | if(result != null){ 37 | runwayResult = result; 38 | status = ""; 39 | } 40 | }catch(Exception e){ 41 | e.printStackTrace(); 42 | } 43 | } 44 | 45 | // this is called each time Processing connects to Runway 46 | // Runway sends information about the current model 47 | public void runwayInfoEvent(JSONObject info){ 48 | // cache the labelToColor data parsed from JSON data to Processing color data 49 | try{ 50 | // access labelToColor object inside the first element of the "inputs" value 51 | JSONObject firstInput = info.getJSONArray("inputs").getJSONObject(0); 52 | //access labelToColor object within the first input 53 | JSONObject labelToColorJSON = firstInput.getJSONObject("labelToColor"); 54 | // access labelToColor object within the first input 55 | JSONObject labelToId = firstInput.getJSONObject("labelToId"); 56 | // allocate labels array 57 | labels = new String[labelToId.size()]; 58 | int labelIndex = 0; 59 | // iterate through each key in the JSON object 60 | for(Object labelObj : labelToColorJSON.keys()){ 61 | // cast the key from Object to String 62 | String label = (String)labelObj; 63 | // parse integer values from the JSON Array values 64 | int[] rgbValues = labelToColorJSON.getJSONArray(label).getIntArray(); 65 | // populate the labelToColour lookup table / hashmap 66 | labelToColor.put(label,color(rgbValues[0],rgbValues[1],rgbValues[2])); 67 | labels[labelIndex++] = label; 68 | } 69 | // update color to the first label 70 | updateLabelColor(); 71 | }catch(Exception e){ 72 | println("error parsing SPADE-COCO model info, unexpected JSON data received:\n" + info.toString()); 73 | e.printStackTrace(); 74 | } 75 | } 76 | 77 | // if anything goes wrong 78 | public void runwayErrorEvent(String message){ 79 | println(message); 80 | } 81 | -------------------------------------------------------------------------------- /examples/HTTP/SPADE_Landscapes_FileSelect/SPADE_Landscapes_FileSelect.pde: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2020 RunwayML Examples 2 | // 3 | // This file is part of RunwayML Examples. 4 | // 5 | // Runway-Examples is free software: you can redistribute it and/or modify 6 | // it under the terms of the GNU General Public License as published by 7 | // the Free Software Foundation, either version 3 of the License, or 8 | // (at your option) any later version. 9 | // 10 | // Runway-Examples is distributed in the hope that it will be useful, 11 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | // GNU General Public License for more details. 14 | // 15 | // You should have received a copy of the GNU General Public License 16 | // along with RunwayML. If not, see . 17 | // 18 | // =========================================================================== 19 | 20 | // RUNWAYML 21 | // www.runwayml.com 22 | 23 | // SPADE Landscapes Demo: 24 | // Receive HTTP messages from Runway 25 | // Running SPADE-Landscapes model 26 | // example by George Profenza 27 | 28 | int currentLabelIndex = 0; 29 | int currentLabelColor; 30 | 31 | String status = ""; 32 | 33 | // Input Image 34 | PImage inputImage; 35 | 36 | 37 | void setup(){ 38 | size(1280,360); 39 | stroke(255); 40 | 41 | setupRunway(); 42 | 43 | } 44 | 45 | void draw(){ 46 | // clear background 47 | background(0); 48 | // Display image (if loaded) 49 | if(inputImage != null){ 50 | image(inputImage,0,0); 51 | } 52 | // display runway result (if any) 53 | if(runwayResult != null){ 54 | image(runwayResult,640,0); 55 | } 56 | // display usage 57 | if(labels != null){ 58 | text("press 's' to select an input image\npress SPACE to send image to Runway",5,15); 59 | } 60 | // separator 61 | line(640,0,640,360); 62 | } 63 | 64 | 65 | void keyPressed(){ 66 | if(key == 's'){ 67 | selectInput("Select an input image to process:", "inputImageSelected"); 68 | } 69 | if(key == ' '){ 70 | status = "waiting for results"; 71 | sendImageToRunway(inputImage); 72 | } 73 | } 74 | 75 | void inputImageSelected(File selection) { 76 | if (selection == null) { 77 | println("Window was closed or the user hit cancel."); 78 | } else { 79 | println("selected " + selection.getAbsolutePath()); 80 | inputImage = loadImage(selection.getAbsolutePath()); 81 | } 82 | } 83 | -------------------------------------------------------------------------------- /examples/HTTP/SPADE_Landscapes_Paint/Runway.pde: -------------------------------------------------------------------------------- 1 | // import Runway library 2 | import com.runwayml.*; 3 | // reference to runway instance 4 | RunwayHTTP runway; 5 | // image from Runway 6 | PImage runwayResult; 7 | 8 | // For this example we only care about label to RGB values associations 9 | HashMap labelToColor = new HashMap(); 10 | HashMap labelToId = new HashMap(); 11 | // store just the SPADE-COCO labels 12 | String[] labels; 13 | 14 | void setupRunway(){ 15 | // setup Runway 16 | runway = new RunwayHTTP(this); 17 | // disable automatic polling: request data manually when a new frame is ready 18 | runway.setAutoUpdate(false); 19 | } 20 | 21 | void sendImageToRunway(){ 22 | runway.query(drawing.get(),ModelUtils.IMAGE_FORMAT_PNG,"semantic_map"); 23 | } 24 | 25 | void updateLabelColor(){ 26 | currentLabelColor = labelToColor.get(labels[currentLabelIndex]); 27 | } 28 | 29 | // this is called when new Runway data is available 30 | void runwayDataEvent(JSONObject runwayData){ 31 | // point the sketch data to the Runway incoming data 32 | String base64ImageString = runwayData.getString("output"); 33 | // try to decode the image from 34 | try{ 35 | PImage result = ModelUtils.fromBase64(base64ImageString); 36 | if(result != null){ 37 | runwayResult = result; 38 | status = ""; 39 | } 40 | }catch(Exception e){ 41 | e.printStackTrace(); 42 | } 43 | } 44 | 45 | // this is called each time Processing connects to Runway 46 | // Runway sends information about the current model 47 | public void runwayInfoEvent(JSONObject info){ 48 | // cache the labelToColor data parsed from JSON data to Processing color data 49 | try{ 50 | // access labelToColor object inside the first element of the "inputs" value 51 | JSONObject firstInput = info.getJSONArray("inputs").getJSONObject(0); 52 | //access labelToColor object within the first input 53 | JSONObject labelToColorJSON = firstInput.getJSONObject("labelToColor"); 54 | // access labelToColor object within the first input 55 | JSONObject labelToId = firstInput.getJSONObject("labelToId"); 56 | // allocate labels array 57 | labels = new String[labelToId.size()]; 58 | int labelIndex = 0; 59 | // iterate through each key in the JSON object 60 | for(Object labelObj : labelToColorJSON.keys()){ 61 | // cast the key from Object to String 62 | String label = (String)labelObj; 63 | // parse integer values from the JSON Array values 64 | int[] rgbValues = labelToColorJSON.getJSONArray(label).getIntArray(); 65 | // populate the labelToColour lookup table / hashmap 66 | labelToColor.put(label,color(rgbValues[0],rgbValues[1],rgbValues[2])); 67 | labels[labelIndex++] = label; 68 | } 69 | // update color to the first label 70 | updateLabelColor(); 71 | }catch(Exception e){ 72 | println("error parsing SPADE-COCO model info, unexpected JSON data received:\n" + info.toString()); 73 | e.printStackTrace(); 74 | } 75 | } 76 | 77 | // if anything goes wrong 78 | public void runwayErrorEvent(String message){ 79 | println(message); 80 | } 81 | -------------------------------------------------------------------------------- /examples/HTTP/SPADE_Landscapes_Paint/SPADE_Landscapes_Paint.pde: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2020 RunwayML Examples 2 | // 3 | // This file is part of RunwayML Examples. 4 | // 5 | // Runway-Examples is free software: you can redistribute it and/or modify 6 | // it under the terms of the GNU General Public License as published by 7 | // the Free Software Foundation, either version 3 of the License, or 8 | // (at your option) any later version. 9 | // 10 | // Runway-Examples is distributed in the hope that it will be useful, 11 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | // GNU General Public License for more details. 14 | // 15 | // You should have received a copy of the GNU General Public License 16 | // along with RunwayML. If not, see . 17 | // 18 | // =========================================================================== 19 | 20 | // RUNWAYML 21 | // www.runwayml.com 22 | 23 | // SPADE Landscapes Demo: 24 | // Receive HTTP messages from Runway 25 | // Running SPADE-Landscapes model 26 | // example by George Profenza 27 | 28 | // drawing layer 29 | PGraphics drawing; 30 | int currentLabelIndex = 0; 31 | int currentLabelColor; 32 | 33 | String status = ""; 34 | 35 | void setup(){ 36 | size(1280,360); 37 | stroke(255); 38 | 39 | setupRunway(); 40 | 41 | //setup drawing layer 42 | drawing = createGraphics(640,360); 43 | drawing.beginDraw(); 44 | drawing.background(0); 45 | drawing.noStroke(); 46 | drawing.endDraw(); 47 | } 48 | 49 | void draw(){ 50 | // clear background 51 | background(0); 52 | // preview drawing 53 | image(drawing,0,0); 54 | // display runway result (if any) 55 | if(runwayResult != null){ 56 | image(runwayResult,640,0); 57 | } 58 | // display usage 59 | if(labels != null){ 60 | text("LEFT/RIGHT = cycle through labels\n" + 61 | "currentLabel: " + labels[currentLabelIndex] + "\n" + 62 | "click to draw\npress SPACE to send image to Runway\n" + status,5,15); 63 | } 64 | // separator 65 | line(640,0,640,360); 66 | } 67 | 68 | void mouseDragged(){ 69 | drawing.beginDraw(); 70 | drawing.fill(currentLabelColor); 71 | drawing.ellipse(constrain(mouseX,0,640),constrain(mouseY,0,360),36,36); 72 | drawing.endDraw(); 73 | } 74 | 75 | void keyPressed(){ 76 | if(keyCode == LEFT && currentLabelIndex > 0){ 77 | currentLabelIndex--; 78 | updateLabelColor(); 79 | } 80 | if(keyCode == RIGHT && currentLabelIndex < labels.length - 1){ 81 | currentLabelIndex++; 82 | updateLabelColor(); 83 | } 84 | if(key == ' '){ 85 | status = "waiting for results"; 86 | sendImageToRunway(); 87 | } 88 | } 89 | -------------------------------------------------------------------------------- /examples/HTTP/Style2PaintsFileSelect/Style2PaintsFileSelect.pde: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2020 RunwayML Examples 2 | // 3 | // This file is part of RunwayML Examples. 4 | // 5 | // Runway-Examples is free software: you can redistribute it and/or modify 6 | // it under the terms of the GNU General Public License as published by 7 | // the Free Software Foundation, either version 3 of the License, or 8 | // (at your option) any later version. 9 | // 10 | // Runway-Examples is distributed in the hope that it will be useful, 11 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | // GNU General Public License for more details. 14 | // 15 | // You should have received a copy of the GNU General Public License 16 | // along with RunwayML. If not, see . 17 | // 18 | // =========================================================================== 19 | 20 | // RUNWAYML 21 | // www.runwayml.com 22 | 23 | // Style2Paints 24 | // Receive HTTP messages from Runway 25 | // Running Style2Paints model 26 | // example by George Profenza 27 | 28 | // import Runway library 29 | import com.runwayml.*; 30 | // reference to runway instance 31 | RunwayHTTP runway; 32 | 33 | PImage runwayResult; 34 | PImage contentImage; 35 | 36 | // status 37 | String status = "Press 'c' to select a content image"; 38 | 39 | void setup(){ 40 | // match sketch size to default model camera setup 41 | size(1200,400); 42 | // setup Runway 43 | runway = new RunwayHTTP(this); 44 | // update manually 45 | runway.setAutoUpdate(false); 46 | } 47 | 48 | void draw(){ 49 | background(0); 50 | // draw content image (if loaded) 51 | if(contentImage != null){ 52 | image(contentImage,0,0); 53 | } 54 | // draw image received from Runway 55 | if(runwayResult != null){ 56 | image(runwayResult,600,0,600,400); 57 | } 58 | // display status 59 | text(status,5,15); 60 | } 61 | 62 | void keyPressed(){ 63 | if(key == 'c'){ 64 | selectInput("Select a content image to process:", "contentImageSelected"); 65 | } 66 | if(key == 's'){ 67 | if(runwayResult != null){ 68 | runwayResult.save(dataPath("result.png")); 69 | } 70 | } 71 | } 72 | 73 | void contentImageSelected(File selection) { 74 | if (selection == null) { 75 | println("Window was closed or the user hit cancel."); 76 | } else { 77 | println("selected " + selection.getAbsolutePath()); 78 | contentImage = loadImage(selection.getAbsolutePath()); 79 | // resize image (adjust as needed) 80 | contentImage.resize(600,400); 81 | // send to Runway 82 | runway.query(contentImage,ModelUtils.IMAGE_FORMAT_JPG,"input_image"); 83 | } 84 | } 85 | 86 | // this is called when new Runway data is available 87 | void runwayDataEvent(JSONObject runwayData){ 88 | // point the sketch data to the Runway incoming data 89 | String base64ImageString = runwayData.getString("output_image"); 90 | // try to decode the image from 91 | try{ 92 | runwayResult = ModelUtils.fromBase64(base64ImageString); 93 | }catch(Exception e){ 94 | e.printStackTrace(); 95 | } 96 | status = "received runway result"; 97 | } 98 | 99 | // this is called each time Processing connects to Runway 100 | // Runway sends information about the current model 101 | public void runwayInfoEvent(JSONObject info){ 102 | println(info); 103 | } 104 | // if anything goes wrong 105 | public void runwayErrorEvent(String message){ 106 | println(message); 107 | } 108 | -------------------------------------------------------------------------------- /examples/HTTP/StyleGAN/StyleGAN2_RandomLatentSpaceWalk: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2020 RunwayML Examples 2 | // 3 | // This file is part of RunwayML Examples. 4 | // 5 | // Runway-Examples is free software: you can redistribute it and/or modify 6 | // it under the terms of the GNU General Public License as published by 7 | // the Free Software Foundation, either version 3 of the License, or 8 | // (at your option) any later version. 9 | // 10 | // Runway-Examples is distributed in the hope that it will be useful, 11 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | // GNU General Public License for more details. 14 | // 15 | // You should have received a copy of the GNU General Public License 16 | // along with RunwayML. If not, see . 17 | // 18 | // =========================================================================== 19 | 20 | // RUNWAYML 21 | // www.runwayml.com 22 | 23 | // StyleGAN2_RandomLatentSpaceWalk Demo: 24 | // Receive HTTP messages from Runway 25 | // Running StyleGAN2 26 | // Sending a random 512 float vector into StyleGAN2 27 | // Interpolates between previous and current vector point 28 | // Example by Moisés Horta Valenzuela (http://moiseshorta.audio) 29 | 30 | // import Runway library 31 | import com.runwayml.*; 32 | 33 | // reference to runway instance 34 | RunwayHTTP runway; 35 | 36 | // storage for received Runway image data 37 | PImage runwayResult; 38 | 39 | // declare input vector as string 40 | String input; 41 | 42 | //declare number of vectors in StyleGAN2 model (512 floats) 43 | int vectors = 512; 44 | //declare arrays for receiving vectors values 45 | float[] z = new float[vectors]; 46 | float[] arrayLerp = new float[vectors]; 47 | String[] zString = new String[vectors]; 48 | // declare lerp speed 49 | float lerpSpeed = 0.005; 50 | 51 | void setup() { 52 | size(1024, 1024); 53 | frameRate(25); 54 | fill(255); 55 | // setup Runway 56 | runway = new RunwayHTTP(this); 57 | // disable automatic polling: request data manually when a new frame is ready 58 | runway.setAutoUpdate(false); 59 | } 60 | 61 | void draw() { 62 | background(0); 63 | // loop to generated a random float between -1 and 1 and input into vector 64 | for(int i = 0; i < (vectors); i++){ 65 | // generates random floats between -1 and 1 66 | z[i] = random(-1, 1); 67 | // lerps between last random float value to the next 68 | arrayLerp[i] = lerp(arrayLerp[i], z[i], lerpSpeed); 69 | String[] _z = str(arrayLerp); 70 | zString = _z; 71 | } 72 | 73 | // joins zString array into one string 74 | String _zString = join(zString, ", "); 75 | //println(_zString); 76 | // random 512 float array gets added to string and sent to Runway 77 | input = "{\"z\":["+_zString+"],\"truncation\":1.0}"; 78 | runway.query(input); 79 | 80 | // display result (if any) 81 | if(runwayResult != null){ 82 | image(runwayResult, 0, 0); 83 | } 84 | } 85 | 86 | // this is called when new Runway data is available 87 | void runwayDataEvent(JSONObject runwayData){ 88 | // point the sketch data to the Runway incoming data 89 | String base64ImageString = runwayData.getString("image"); 90 | // try to decode the image from 91 | try{ 92 | PImage result = ModelUtils.fromBase64(base64ImageString); 93 | if(result != null){ 94 | runwayResult = result; 95 | } 96 | }catch(Exception e){ 97 | e.printStackTrace(); 98 | } 99 | } 100 | -------------------------------------------------------------------------------- /examples/HTTP/UGATIT/UGATIT.pde: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2020 RunwayML Examples 2 | // 3 | // This file is part of RunwayML Examples. 4 | // 5 | // Runway-Examples is free software: you can redistribute it and/or modify 6 | // it under the terms of the GNU General Public License as published by 7 | // the Free Software Foundation, either version 3 of the License, or 8 | // (at your option) any later version. 9 | // 10 | // Runway-Examples is distributed in the hope that it will be useful, 11 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | // GNU General Public License for more details. 14 | // 15 | // You should have received a copy of the GNU General Public License 16 | // along with RunwayML. If not, see . 17 | // 18 | // =========================================================================== 19 | 20 | // RUNWAYML 21 | // www.runwayml.com 22 | 23 | // UGATIT 24 | // Receive HTTP messages from Runway 25 | // Running UGATIT model 26 | // example by George Profenza 27 | 28 | // import Runway library 29 | import com.runwayml.*; 30 | // reference to runway instance 31 | RunwayHTTP runway; 32 | 33 | PImage runwayResult; 34 | PImage contentImage; 35 | 36 | // status 37 | String status = "Press 'c' to select a content image"; 38 | 39 | void setup(){ 40 | // match sketch size to default model camera setup 41 | size(1200,400); 42 | // setup Runway 43 | runway = new RunwayHTTP(this); 44 | // update manually 45 | runway.setAutoUpdate(false); 46 | } 47 | 48 | void draw(){ 49 | background(0); 50 | // draw content image (if loaded) 51 | if(contentImage != null){ 52 | image(contentImage,0,0); 53 | } 54 | // draw image received from Runway 55 | if(runwayResult != null){ 56 | image(runwayResult,600,0); 57 | } 58 | // display status 59 | text(status,5,15); 60 | } 61 | 62 | void keyPressed(){ 63 | if(key == 'c'){ 64 | selectInput("Select a content image to process:", "contentImageSelected"); 65 | } 66 | if(key == 's'){ 67 | if(runwayResult != null){ 68 | runwayResult.save(dataPath("result.png")); 69 | } 70 | } 71 | } 72 | 73 | void contentImageSelected(File selection) { 74 | if (selection == null) { 75 | println("Window was closed or the user hit cancel."); 76 | } else { 77 | println("selected " + selection.getAbsolutePath()); 78 | contentImage = loadImage(selection.getAbsolutePath()); 79 | // resize image (adjust as needed) 80 | contentImage.resize(600,400); 81 | // send to Runway 82 | runway.query(contentImage); 83 | } 84 | } 85 | 86 | // this is called when new Runway data is available 87 | void runwayDataEvent(JSONObject runwayData){ 88 | // point the sketch data to the Runway incoming data 89 | String base64ImageString = runwayData.getString("image"); 90 | // try to decode the image from 91 | try{ 92 | runwayResult = ModelUtils.fromBase64(base64ImageString); 93 | }catch(Exception e){ 94 | e.printStackTrace(); 95 | } 96 | status = "received runway result"; 97 | } 98 | 99 | // this is called each time Processing connects to Runway 100 | // Runway sends information about the current model 101 | public void runwayInfoEvent(JSONObject info){ 102 | println(info); 103 | } 104 | // if anything goes wrong 105 | public void runwayErrorEvent(String message){ 106 | println(message); 107 | } 108 | -------------------------------------------------------------------------------- /examples/HTTP/VisualImportanceFileSelect/VisualImportanceFileSelect.pde: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2020 RunwayML Examples 2 | // 3 | // This file is part of RunwayML Examples. 4 | // 5 | // Runway-Examples is free software: you can redistribute it and/or modify 6 | // it under the terms of the GNU General Public License as published by 7 | // the Free Software Foundation, either version 3 of the License, or 8 | // (at your option) any later version. 9 | // 10 | // Runway-Examples is distributed in the hope that it will be useful, 11 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | // GNU General Public License for more details. 14 | // 15 | // You should have received a copy of the GNU General Public License 16 | // along with RunwayML. If not, see . 17 | // 18 | // =========================================================================== 19 | 20 | // RUNWAYML 21 | // www.runwayml.com 22 | 23 | // Visual-Importance 24 | // Receive HTTP messages from Runway 25 | // Running Visual-Importance model 26 | // example by George Profenza 27 | 28 | // import Runway library 29 | import com.runwayml.*; 30 | // reference to runway instance 31 | RunwayHTTP runway; 32 | 33 | PImage runwayResult; 34 | 35 | // status 36 | String status = ""; 37 | 38 | // Input Image 39 | PImage inputImage; 40 | 41 | void setup(){ 42 | // match sketch size to default model camera setup 43 | size(1200,400); 44 | // setup Runway 45 | runway = new RunwayHTTP(this); 46 | // update manually 47 | runway.setAutoUpdate(false); 48 | } 49 | 50 | void draw(){ 51 | background(0); 52 | // Display image (if loaded) 53 | if(inputImage != null){ 54 | image(inputImage,0,0); 55 | } 56 | // draw image received from Runway 57 | if(runwayResult != null){ 58 | image(runwayResult,600,0); 59 | } 60 | // display status 61 | text("press 's' to select an input image\npress SPACE to send image to Runway\n"+status,5,15); 62 | } 63 | 64 | void keyPressed(){ 65 | if(key == 's'){ 66 | selectInput("Select an input image to process:", "inputImageSelected"); 67 | } 68 | if(key == ' ' && inputImage != null){ 69 | status= "waiting for results"; 70 | // send image to runway 71 | runway.query(inputImage); 72 | } 73 | } 74 | 75 | void inputImageSelected(File selection) { 76 | if (selection == null) { 77 | println("Window was closed or the user hit cancel."); 78 | } else { 79 | println("selected " + selection.getAbsolutePath()); 80 | inputImage = loadImage(selection.getAbsolutePath()); 81 | } 82 | } 83 | 84 | // this is called when new Runway data is available 85 | void runwayDataEvent(JSONObject runwayData){ 86 | // point the sketch data to the Runway incoming data 87 | String base64ImageString = runwayData.getString("image"); 88 | // try to decode the image from 89 | try{ 90 | runwayResult = ModelUtils.fromBase64(base64ImageString); 91 | }catch(Exception e){ 92 | e.printStackTrace(); 93 | } 94 | status = "received runway result"; 95 | } 96 | 97 | // this is called each time Processing connects to Runway 98 | // Runway sends information about the current model 99 | public void runwayInfoEvent(JSONObject info){ 100 | println(info); 101 | } 102 | // if anything goes wrong 103 | public void runwayErrorEvent(String message){ 104 | println(message); 105 | } 106 | -------------------------------------------------------------------------------- /examples/HTTP/YOLACT/YOLACT.pde: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2020 RunwayML Examples 2 | // 3 | // This file is part of RunwayML Examples. 4 | // 5 | // Runway-Examples is free software: you can redistribute it and/or modify 6 | // it under the terms of the GNU General Public License as published by 7 | // the Free Software Foundation, either version 3 of the License, or 8 | // (at your option) any later version. 9 | // 10 | // Runway-Examples is distributed in the hope that it will be useful, 11 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | // GNU General Public License for more details. 14 | // 15 | // You should have received a copy of the GNU General Public License 16 | // along with RunwayML. If not, see . 17 | // 18 | // =========================================================================== 19 | 20 | // RUNWAYML 21 | // www.runwayml.com 22 | 23 | // YOLACT 24 | // Receive HTTP messages from Runway 25 | // Running YOLACT model 26 | // example by George Profenza 27 | 28 | // import video library 29 | import processing.video.*; 30 | 31 | // import Runway library 32 | import com.runwayml.*; 33 | // reference to runway instance 34 | RunwayHTTP runway; 35 | 36 | PImage runwayResult; 37 | 38 | // periocally to be updated using millis() 39 | int lastMillis; 40 | // how often should the above be updated and a time action take place ? 41 | int waitTime = 2000; 42 | 43 | // reference to the camera 44 | Capture camera; 45 | 46 | // status 47 | String status = "waiting ~"+(waitTime/1000)+"s"; 48 | 49 | void setup(){ 50 | // match sketch size to default model camera setup 51 | size(1200,400); 52 | // setup Runway 53 | runway = new RunwayHTTP(this); 54 | // update manually 55 | runway.setAutoUpdate(false); 56 | // setup camera 57 | camera = new Capture(this,640,480); 58 | camera.start(); 59 | // setup timer 60 | lastMillis = millis(); 61 | } 62 | 63 | void draw(){ 64 | background(0); 65 | // update timer 66 | int currentMillis = millis(); 67 | // if the difference between current millis and last time we checked past the wait time 68 | if(currentMillis - lastMillis >= waitTime){ 69 | status = "sending image to Runway"; 70 | // call the timed function 71 | sendFrameToRunway(); 72 | // update lastMillis, preparing for another wait 73 | lastMillis = currentMillis; 74 | } 75 | // draw image received from Runway 76 | if(runwayResult != null){ 77 | image(runwayResult,600,0); 78 | } 79 | // draw camera feed 80 | image(camera,0,0,600,400); 81 | // display status 82 | text(status,5,15); 83 | } 84 | 85 | void sendFrameToRunway(){ 86 | // nothing to send if there's no new camera data available 87 | if(camera.available() == false){ 88 | return; 89 | } 90 | // read a new frame 91 | camera.read(); 92 | // crop image to Runway input format (600x400) 93 | PImage image = camera.get(0,0,600,400); 94 | // query Runway with webcam image 95 | runway.query(image,ModelUtils.IMAGE_FORMAT_JPG,"input_image"); 96 | } 97 | 98 | 99 | // this is called when new Runway data is available 100 | void runwayDataEvent(JSONObject runwayData){ 101 | // point the sketch data to the Runway incoming data 102 | String base64ImageString = runwayData.getString("output_image"); 103 | // try to decode the image from 104 | try{ 105 | runwayResult = ModelUtils.fromBase64(base64ImageString); 106 | }catch(Exception e){ 107 | e.printStackTrace(); 108 | } 109 | status = "received runway result"; 110 | } 111 | 112 | // this is called each time Processing connects to Runway 113 | // Runway sends information about the current model 114 | public void runwayInfoEvent(JSONObject info){ 115 | println(info); 116 | } 117 | // if anything goes wrong 118 | public void runwayErrorEvent(String message){ 119 | println(message); 120 | } 121 | -------------------------------------------------------------------------------- /examples/HTTP/YOLACTFileSelect/YOLACTFileSelect.pde: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2020 RunwayML Examples 2 | // 3 | // This file is part of RunwayML Examples. 4 | // 5 | // Runway-Examples is free software: you can redistribute it and/or modify 6 | // it under the terms of the GNU General Public License as published by 7 | // the Free Software Foundation, either version 3 of the License, or 8 | // (at your option) any later version. 9 | // 10 | // Runway-Examples is distributed in the hope that it will be useful, 11 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | // GNU General Public License for more details. 14 | // 15 | // You should have received a copy of the GNU General Public License 16 | // along with RunwayML. If not, see . 17 | // 18 | // =========================================================================== 19 | 20 | // RUNWAYML 21 | // www.runwayml.com 22 | 23 | // YOLACT 24 | // Receive HTTP messages from Runway 25 | // Running YOLACT model 26 | // example by George Profenza 27 | 28 | // import Runway library 29 | import com.runwayml.*; 30 | // reference to runway instance 31 | RunwayHTTP runway; 32 | 33 | 34 | PImage runwayResult; 35 | 36 | // status 37 | String status = ""; 38 | 39 | // Input Image 40 | PImage inputImage; 41 | 42 | void setup(){ 43 | // match sketch size to default model camera setup 44 | size(1200,400); 45 | // setup Runway 46 | runway = new RunwayHTTP(this); 47 | // update manually 48 | runway.setAutoUpdate(false); 49 | } 50 | 51 | void draw(){ 52 | background(0); 53 | // Display image (if loaded) 54 | if(inputImage != null){ 55 | image(inputImage,0,0); 56 | } 57 | // draw image received from Runway 58 | if(runwayResult != null){ 59 | image(runwayResult,600,0); 60 | } 61 | // display status 62 | text("press 's' to select an input image\npress SPACE to send image to Runway\n"+status,5,15); 63 | } 64 | 65 | void keyPressed(){ 66 | if(key == 's'){ 67 | selectInput("Select an input image to process:", "inputImageSelected"); 68 | } 69 | if(key == ' ' && inputImage != null){ 70 | status= "waiting for results"; 71 | // send image to runway 72 | runway.query(inputImage,ModelUtils.IMAGE_FORMAT_JPG,"input_image"); 73 | } 74 | } 75 | 76 | void inputImageSelected(File selection) { 77 | if (selection == null) { 78 | println("Window was closed or the user hit cancel."); 79 | } else { 80 | println("selected " + selection.getAbsolutePath()); 81 | inputImage = loadImage(selection.getAbsolutePath()); 82 | // resize or crop as needed 83 | inputImage.resize(600,400); 84 | } 85 | } 86 | 87 | // this is called when new Runway data is available 88 | void runwayDataEvent(JSONObject runwayData){ 89 | // point the sketch data to the Runway incoming data 90 | String base64ImageString = runwayData.getString("output_image"); 91 | // try to decode the image from 92 | try{ 93 | runwayResult = ModelUtils.fromBase64(base64ImageString); 94 | }catch(Exception e){ 95 | e.printStackTrace(); 96 | } 97 | status = "received runway result"; 98 | } 99 | 100 | // this is called each time Processing connects to Runway 101 | // Runway sends information about the current model 102 | public void runwayInfoEvent(JSONObject info){ 103 | println(info); 104 | } 105 | // if anything goes wrong 106 | public void runwayErrorEvent(String message){ 107 | println(message); 108 | } 109 | -------------------------------------------------------------------------------- /examples/HTTP/attnGANBasics/attnGANBasics.pde: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2020 Runway ML Examples 2 | // 3 | // This file is part of Runway ML Examples. 4 | // 5 | // Runway-Examples is free software: you can redistribute it and/or modify 6 | // it under the terms of the GNU General Public License as published by 7 | // the Free Software Foundation, either version 3 of the License, or 8 | // (at your option) any later version. 9 | // 10 | // Runway-Examples is distributed in the hope that it will be useful, 11 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | // GNU General Public License for more details. 14 | // 15 | // You should have received a copy of the GNU General Public License 16 | // along with RunwayML. If not, see . 17 | // 18 | // =========================================================================== 19 | 20 | // RUNWAYML 21 | // www.runwayml.com 22 | 23 | // AttnGAN Demo 24 | // Send OSC text messages to Runway and generate images 25 | // example based on https://github.com/runwayml/processing/blob/master/attnGAN/attnGAN.pde adapted by George Profenza 26 | 27 | // import Runway library 28 | import com.runwayml.*; 29 | // reference to runway instance 30 | RunwayHTTP runway; 31 | 32 | // The caption to send 33 | String data = "{ \"caption\": \"a blue ocean\"}"; 34 | 35 | void setup() { 36 | size(256, 256); 37 | frameRate(25); 38 | // setup Runway 39 | runway = new RunwayHTTP(this); 40 | // don't send messages to Runway continuously 41 | runway.setAutoUpdate(false); 42 | } 43 | 44 | void draw() { 45 | background(0); 46 | text("press 's' to send text to Runway",5,15); 47 | } 48 | 49 | void keyPressed() { 50 | if(key == 's'){ 51 | runway.query(data); 52 | } 53 | } 54 | -------------------------------------------------------------------------------- /examples/HTTP/attnGANPrompt/attnGANPrompt.pde: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2020 Runway ML Examples 2 | // 3 | // This file is part of Runway ML Examples. 4 | // 5 | // Runway-Examples is free software: you can redistribute it and/or modify 6 | // it under the terms of the GNU General Public License as published by 7 | // the Free Software Foundation, either version 3 of the License, or 8 | // (at your option) any later version. 9 | // 10 | // Runway-Examples is distributed in the hope that it will be useful, 11 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | // GNU General Public License for more details. 14 | // 15 | // You should have received a copy of the GNU General Public License 16 | // along with RunwayML. If not, see . 17 | // 18 | // =========================================================================== 19 | 20 | // RUNWAYML 21 | // www.runwayml.com 22 | 23 | // AttnGAN Demo 24 | // Send OSC text messages to Runway and generate images 25 | // example based on https://github.com/runwayml/processing/blob/master/attnGAN/attnGAN.pde adapted by George Profenza 26 | 27 | // import Runway library 28 | import com.runwayml.*; 29 | // reference to runway instance 30 | RunwayHTTP runway; 31 | 32 | // result image will be stored here 33 | PImage runwayResult; 34 | 35 | void setup() { 36 | size(256, 256); 37 | frameRate(25); 38 | // setup Runway 39 | runway = new RunwayHTTP(this); 40 | // don't send messages to Runway continuously 41 | runway.setAutoUpdate(false); 42 | } 43 | 44 | void draw() { 45 | background(0); 46 | if(runwayResult != null){ 47 | image(runwayResult,0,0); 48 | } 49 | text("press 's' to send text to Runway",5,15); 50 | } 51 | 52 | void keyPressed() { 53 | if(key == 's'){ 54 | String caption = (String)javax.swing.JOptionPane.showInputDialog(frame, "Text", "AttnGAN Input Text", javax.swing.JOptionPane.PLAIN_MESSAGE); 55 | if(caption != null){ 56 | runway.query("{ \"caption\": \""+ caption +"\"}"); 57 | } 58 | } 59 | } 60 | 61 | // this is called when new Runway data is available 62 | void runwayDataEvent(JSONObject runwayData){ 63 | // point the sketch data to the Runway incoming data 64 | String base64ImageString = runwayData.getString("result"); 65 | // try to decode the image from 66 | try{ 67 | PImage result = ModelUtils.fromBase64(base64ImageString); 68 | if(result != null){ 69 | runwayResult = result; 70 | } 71 | }catch(Exception e){ 72 | e.printStackTrace(); 73 | } 74 | } 75 | -------------------------------------------------------------------------------- /examples/HTTP/cnOCR/cnOCR.pde: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2020 RunwayML Examples 2 | // 3 | // This file is part of RunwayML Examples. 4 | // 5 | // Runway-Examples is free software: you can redistribute it and/or modify 6 | // it under the terms of the GNU General Public License as published by 7 | // the Free Software Foundation, either version 3 of the License, or 8 | // (at your option) any later version. 9 | // 10 | // Runway-Examples is distributed in the hope that it will be useful, 11 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | // GNU General Public License for more details. 14 | // 15 | // You should have received a copy of the GNU General Public License 16 | // along with RunwayML. If not, see . 17 | // 18 | // =========================================================================== 19 | 20 | // RUNWAYML 21 | // www.runwayml.com 22 | 23 | // cnOCR Demo: 24 | // Receive HTTP messages from Runway 25 | // Running cnOCR model 26 | // example by George Profenza 27 | 28 | // import Runway library 29 | import com.runwayml.*; 30 | // reference to runway instance 31 | RunwayHTTP runway; 32 | 33 | // The data coming in from Runway as a JSON Object {} 34 | JSONObject data; 35 | 36 | void setup() { 37 | size(500, 300); 38 | frameRate(3); 39 | fill(255); 40 | // setup Runway 41 | runway = new RunwayHTTP(this); 42 | } 43 | 44 | void draw() { 45 | background(0); 46 | 47 | // Display captions 48 | drawResult(); 49 | } 50 | 51 | 52 | // A function to display the captions 53 | void drawResult() { 54 | // Only if there are any captions 55 | if (data != null) { 56 | // a single string to hold all characters 57 | String results = ""; 58 | // access Runway data 59 | JSONArray characters = data.getJSONArray("characters"); 60 | // for each element in the erray 61 | for(int i = 0 ; i < characters.size(); i++){ 62 | // access each sub-array 63 | JSONArray characterData = characters.getJSONArray(i); 64 | // for each string in the subarray 65 | for(int j = 0 ; j < characterData.size(); j++){ 66 | // append the string 67 | results += characterData.getString(j); 68 | // if there are more characters, space them 69 | if(j < characterData.size()) { 70 | results += ' '; 71 | } 72 | } 73 | } 74 | text(results, 100, 100); 75 | } 76 | } 77 | 78 | // this is called when new Runway data is available 79 | void runwayDataEvent(JSONObject runwayData){ 80 | // point the sketch data to the Runway incoming data 81 | data = runwayData; 82 | } 83 | -------------------------------------------------------------------------------- /examples/HTTP/face_landmarks/face_landmarks.pde: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2020 RunwayML Examples 2 | // 3 | // This file is part of RunwayML Examples. 4 | // 5 | // Runway-Examples is free software: you can redistribute it and/or modify 6 | // it under the terms of the GNU General Public License as published by 7 | // the Free Software Foundation, either version 3 of the License, or 8 | // (at your option) any later version. 9 | // 10 | // Runway-Examples is distributed in the hope that it will be useful, 11 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | // GNU General Public License for more details. 14 | // 15 | // You should have received a copy of the GNU General Public License 16 | // along with RunwayML. If not, see . 17 | // 18 | // =========================================================================== 19 | 20 | // RUNWAYML 21 | // www.runwayml.com 22 | 23 | // face_landmarks Demo: 24 | // Receive OSC messages from Runway 25 | // Running face_landmarks model 26 | // original example by Joel Matthys @jwmatthys, adapted by George Profenza 27 | 28 | // import Runway library 29 | import com.runwayml.*; 30 | // reference to runway instance 31 | RunwayHTTP runway; 32 | 33 | // This array will hold all the humans detected 34 | JSONObject data; 35 | 36 | void setup(){ 37 | // match sketch size to default model camera setup 38 | size(600,400); 39 | fill(9,130,250); 40 | noStroke(); 41 | // setup Runway 42 | runway = new RunwayHTTP(this); 43 | } 44 | 45 | void draw(){ 46 | background(0); 47 | // use the utiliy class to draw PoseNet parts 48 | if(data != null){ 49 | JSONArray landmarks = data.getJSONArray("points"); 50 | if (landmarks != null) 51 | { 52 | for (int k = 0; k < landmarks.size(); k++) { 53 | // Body parts are relative to width and weight of the input 54 | JSONArray point = landmarks.getJSONArray(k); 55 | float x = point.getFloat(0); 56 | float y = point.getFloat(1); 57 | ellipse(x * width, y * height, 10, 10); 58 | } 59 | } 60 | } 61 | } 62 | 63 | // this is called when new Runway data is available 64 | void runwayDataEvent(JSONObject runwayData){ 65 | // point the sketch data to the Runway incoming data 66 | data = runwayData; 67 | } 68 | -------------------------------------------------------------------------------- /examples/HTTP/im2txt/im2txt.pde: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2020 RunwayML Examples 2 | // 3 | // This file is part of RunwayML Examples. 4 | // 5 | // Runway-Examples is free software: you can redistribute it and/or modify 6 | // it under the terms of the GNU General Public License as published by 7 | // the Free Software Foundation, either version 3 of the License, or 8 | // (at your option) any later version. 9 | // 10 | // Runway-Examples is distributed in the hope that it will be useful, 11 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | // GNU General Public License for more details. 14 | // 15 | // You should have received a copy of the GNU General Public License 16 | // along with RunwayML. If not, see . 17 | // 18 | // =========================================================================== 19 | 20 | // RUNWAYML 21 | // www.runwayml.com 22 | 23 | // im2txt Demo: 24 | // Receive HTTP messages from Runway 25 | // Running im2txt model 26 | // Original example by Cris Valenzuela, Anastasis Germanidis, Gene Kogan, adapted by George Profenza 27 | 28 | // import Runway library 29 | import com.runwayml.*; 30 | // reference to runway instance 31 | RunwayHTTP runway; 32 | 33 | // The data coming in from Runway as a JSON Object {} 34 | JSONObject data; 35 | 36 | void setup() { 37 | size(500, 300); 38 | frameRate(3); 39 | fill(255); 40 | stroke(255); 41 | // setup Runway 42 | runway = new RunwayHTTP(this); 43 | } 44 | 45 | void draw() { 46 | background(0); 47 | 48 | // Display captions 49 | drawCaptions(); 50 | } 51 | 52 | 53 | // A function to display the captions 54 | void drawCaptions() { 55 | // Only if there are any captions 56 | if (data != null) { 57 | String results = data.getString("caption"); 58 | text(results, 100, 100); 59 | } 60 | } 61 | 62 | // this is called when new Runway data is available 63 | void runwayDataEvent(JSONObject runwayData){ 64 | // point the sketch data to the Runway incoming data 65 | data = runwayData; 66 | } 67 | -------------------------------------------------------------------------------- /examples/HTTP/im2txtFileSelect/im2txtFileSelect.pde: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2020 RunwayML Examples 2 | // 3 | // This file is part of RunwayML Examples. 4 | // 5 | // Runway-Examples is free software: you can redistribute it and/or modify 6 | // it under the terms of the GNU General Public License as published by 7 | // the Free Software Foundation, either version 3 of the License, or 8 | // (at your option) any later version. 9 | // 10 | // Runway-Examples is distributed in the hope that it will be useful, 11 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | // GNU General Public License for more details. 14 | // 15 | // You should have received a copy of the GNU General Public License 16 | // along with RunwayML. If not, see . 17 | // 18 | // =========================================================================== 19 | 20 | // RUNWAYML 21 | // www.runwayml.com 22 | 23 | // im2txt Demo: 24 | // Receive HTTP messages from Runway 25 | // Running im2txt model 26 | // Original example by Cris Valenzuela, Anastasis Germanidis, Gene Kogan, adapted by George Profenza 27 | 28 | // import Runway library 29 | import com.runwayml.*; 30 | // reference to runway instance 31 | RunwayHTTP runway; 32 | 33 | // The data coming in from Runway as a JSON Object {} 34 | JSONObject data; 35 | 36 | // Input Image 37 | PImage inputImage; 38 | 39 | void setup() { 40 | size(500, 300); 41 | fill(255); 42 | stroke(255); 43 | // setup Runway 44 | runway = new RunwayHTTP(this); 45 | } 46 | 47 | void draw() { 48 | background(0); 49 | 50 | // Display image (if loaded) 51 | if(inputImage != null){ 52 | image(inputImage,0,0); 53 | } 54 | 55 | // Display instructions 56 | text("press 's' to select an input image\npress SPACE to query Runway",5,15); 57 | 58 | // Display captions 59 | drawCaptions(); 60 | } 61 | 62 | 63 | // A function to display the captions 64 | void drawCaptions() { 65 | // Only if there are any captions 66 | if (data != null) { 67 | String results = data.getString("caption"); 68 | text(results, 100, 100); 69 | } 70 | } 71 | 72 | void keyPressed(){ 73 | if(key == 's'){ 74 | selectInput("Select an input image to process:", "inputImageSelected"); 75 | } 76 | if(key == ' '){ 77 | if(inputImage != null){ 78 | runway.query(inputImage); 79 | } 80 | } 81 | } 82 | 83 | void inputImageSelected(File selection) { 84 | if (selection == null) { 85 | println("Window was closed or the user hit cancel."); 86 | } else { 87 | println("selected " + selection.getAbsolutePath()); 88 | inputImage = loadImage(selection.getAbsolutePath()); 89 | } 90 | } 91 | 92 | // this is called when new Runway data is available 93 | void runwayDataEvent(JSONObject runwayData){ 94 | // point the sketch data to the Runway incoming data 95 | data = runwayData; 96 | } 97 | -------------------------------------------------------------------------------- /examples/HTTP/im2txtWebcam/im2txtWebcam.pde: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2020 RunwayML Examples 2 | // 3 | // This file is part of RunwayML Examples. 4 | // 5 | // Runway-Examples is free software: you can redistribute it and/or modify 6 | // it under the terms of the GNU General Public License as published by 7 | // the Free Software Foundation, either version 3 of the License, or 8 | // (at your option) any later version. 9 | // 10 | // Runway-Examples is distributed in the hope that it will be useful, 11 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | // GNU General Public License for more details. 14 | // 15 | // You should have received a copy of the GNU General Public License 16 | // along with RunwayML. If not, see . 17 | // 18 | // =========================================================================== 19 | 20 | // RUNWAYML 21 | // www.runwayml.com 22 | 23 | // im2txt Demo: 24 | // Receive HTTP messages from Runway 25 | // Running im2txt model 26 | 27 | // import video library 28 | import processing.video.*; 29 | // import Runway library 30 | import com.runwayml.*; 31 | // reference to runway instance 32 | RunwayHTTP runway; 33 | 34 | // The data coming in from Runway as a JSON Object {} 35 | JSONObject data; 36 | 37 | // reference to the camera 38 | Capture camera; 39 | 40 | // periocally to be updated using millis() 41 | int lastMillis; 42 | // how often should the above be updated and a time action take place ? 43 | // takes about 2-25s (2000-2500ms) for Runway to process a 600x400 im2txt frame on an older CPU 44 | int waitTime = 2500; 45 | 46 | void setup() { 47 | size(600, 400); 48 | frameRate(3); 49 | fill(255); 50 | stroke(255); 51 | // setup Runway 52 | runway = new RunwayHTTP(this); 53 | // disable automatic polling: request data manually when a new frame is ready 54 | runway.setAutoUpdate(false); 55 | // setup camera 56 | camera = new Capture(this,640,480); 57 | camera.start(); 58 | // setup timer 59 | lastMillis = millis(); 60 | } 61 | 62 | void draw() { 63 | // update timer 64 | int currentMillis = millis(); 65 | // if the difference between current millis and last time we checked past the wait time 66 | if(currentMillis - lastMillis >= waitTime){ 67 | // call the timed function 68 | sendFrameToRunway(); 69 | // update lastMillis, preparing for another wait 70 | lastMillis = currentMillis; 71 | } 72 | background(0); 73 | // draw webcam image 74 | image(camera,0,0); 75 | 76 | // Display captions 77 | drawCaptions(); 78 | } 79 | 80 | 81 | // A function to display the captions 82 | void drawCaptions() { 83 | // Only if there are any captions 84 | if (data != null) { 85 | String results = data.getString("caption"); 86 | text(results, 100, 100); 87 | } 88 | } 89 | 90 | void sendFrameToRunway(){ 91 | // nothing to send if there's no new camera data available 92 | if(camera.available() == false){ 93 | return; 94 | } 95 | // read a new frame 96 | camera.read(); 97 | // crop image to Runway input format (600x400) 98 | PImage image = camera.get(0,0,600,400); 99 | // query Runway with webcam image 100 | runway.query(image); 101 | } 102 | 103 | // this is called when new Runway data is available 104 | void runwayDataEvent(JSONObject runwayData){ 105 | // point the sketch data to the Runway incoming data 106 | data = runwayData; 107 | } 108 | -------------------------------------------------------------------------------- /examples/OSC/GPT2/GPT2.pde: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2020 Runway ML Examples 2 | // 3 | // This file is part of Runway ML Examples. 4 | // 5 | // Runway-Examples is free software: you can redistribute it and/or modify 6 | // it under the terms of the GNU General Public License as published by 7 | // the Free Software Foundation, either version 3 of the License, or 8 | // (at your option) any later version. 9 | // 10 | // Runway-Examples is distributed in the hope that it will be useful, 11 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | // GNU General Public License for more details. 14 | // 15 | // You should have received a copy of the GNU General Public License 16 | // along with Runway. If not, see . 17 | // 18 | // =========================================================================== 19 | 20 | // RUNWAYML 21 | // www.runwayml.com 22 | 23 | // GPT2 Demo: 24 | // Send seed text and eceive OSC messages from Runway 25 | // Running GPT2 model 26 | // original example by https://github.com/maybay21, adapted by George Profenza 27 | 28 | 29 | // import controlp5 30 | import controlP5.*; 31 | //create controlP5 instance 32 | ControlP5 cp5; 33 | 34 | //import oscP5 35 | import oscP5.*; 36 | 37 | // import Runway library 38 | import com.runwayml.*; 39 | // reference to runway instance 40 | RunwayOSC runway; 41 | 42 | String textValue = ""; 43 | String text_output; 44 | JSONObject data; 45 | JSONObject json_message; 46 | String json_output; 47 | 48 | void setup() { 49 | //create canvas 50 | size(900,700); 51 | 52 | // setup Runway 53 | runway = new RunwayOSC(this); 54 | 55 | //create a font 56 | PFont font = createFont("arial",20); 57 | 58 | cp5 = new ControlP5(this); 59 | //definetextField 60 | cp5.addTextfield("input") 61 | .setPosition(20,40) 62 | .setSize(200,40) 63 | .setFont(font) 64 | .setFocus(true) 65 | .setColor(color(0,255,0)) 66 | ; 67 | 68 | 69 | textFont(font); 70 | } 71 | 72 | void draw() { 73 | //create black background 74 | background(0); 75 | fill(255); 76 | 77 | //display the text we are writing to the screen 78 | text(cp5.get(Textfield.class,"input").getText(), 20,180); 79 | 80 | //get the returned results and display them on the interface 81 | text(textValue, 20,80); 82 | if(text_output != null){ 83 | fill(255); 84 | stroke(255); 85 | textSize(12); 86 | text(text_output, 320, 10, 400, height); 87 | } 88 | } 89 | 90 | 91 | //clear the text field after input 92 | void clear() { 93 | cp5.get(Textfield.class,"textValue").clear(); 94 | } 95 | 96 | //send the text from ou interface to RunwayML 97 | void input(String theText) { 98 | //create json object 99 | json_message = new JSONObject(); 100 | 101 | //add the text from the textfield and seed 102 | json_message.setString("prompt", theText); 103 | json_message.setInt("seed", 1); 104 | print(json_message); 105 | json_output = json_message.toString(); 106 | 107 | //send the message to RunwayML 108 | runway.query(json_message.format(-1)); 109 | } 110 | 111 | // this is called when new Runway data is available 112 | void runwayDataEvent(JSONObject runwayData){ 113 | // point the sketch data to the Runway incoming data 114 | data = runwayData; 115 | //get the value of the "text" key 116 | text_output = data.getString("generated_text"); 117 | } 118 | -------------------------------------------------------------------------------- /examples/OSC/PoseNetBasics/PoseNetBasics.pde: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2020 RunwayML Examples 2 | // 3 | // This file is part of RunwayML Examples. 4 | // 5 | // Runway-Examples is free software: you can redistribute it and/or modify 6 | // it under the terms of the GNU General Public License as published by 7 | // the Free Software Foundation, either version 3 of the License, or 8 | // (at your option) any later version. 9 | // 10 | // Runway-Examples is distributed in the hope that it will be useful, 11 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | // GNU General Public License for more details. 14 | // 15 | // You should have received a copy of the GNU General Public License 16 | // along with RunwayML. If not, see . 17 | // 18 | // =========================================================================== 19 | 20 | // RUNWAYML 21 | // www.runwayml.com 22 | 23 | // PoseNet Demo: 24 | // Receive OSC messages from Runway 25 | // Running PoseNet model 26 | // original example by Anastasis Germanidis, adapted by George Profenza 27 | 28 | // import OSC libraries 29 | import oscP5.*; 30 | // import Runway library 31 | import com.runwayml.*; 32 | // reference to runway instance 33 | RunwayOSC runway; 34 | 35 | // This array will hold all the humans detected 36 | JSONObject data; 37 | 38 | void setup(){ 39 | // match sketch size to default model camera setup 40 | size(600,400); 41 | // setup Runway 42 | runway = new RunwayOSC(this); 43 | } 44 | 45 | void draw(){ 46 | background(0); 47 | // use the utiliy class to draw PoseNet parts 48 | runway.drawPoseNetParts(data,10); 49 | } 50 | 51 | // this is called when new Runway data is available 52 | void runwayDataEvent(JSONObject runwayData){ 53 | // point the sketch data to the Runway incoming data 54 | data = runwayData; 55 | } 56 | -------------------------------------------------------------------------------- /examples/OSC/attnGANBasics/attnGANBasics.pde: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2020 Runway ML Examples 2 | // 3 | // This file is part of Runway ML Examples. 4 | // 5 | // Runway-Examples is free software: you can redistribute it and/or modify 6 | // it under the terms of the GNU General Public License as published by 7 | // the Free Software Foundation, either version 3 of the License, or 8 | // (at your option) any later version. 9 | // 10 | // Runway-Examples is distributed in the hope that it will be useful, 11 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | // GNU General Public License for more details. 14 | // 15 | // You should have received a copy of the GNU General Public License 16 | // along with RunwayML. If not, see . 17 | // 18 | // =========================================================================== 19 | 20 | // RUNWAYML 21 | // www.runwayml.com 22 | 23 | // AttnGAN Demo 24 | // Send OSC text messages to Runway and generate images 25 | // example based on https://github.com/runwayml/processing/blob/master/attnGAN/attnGAN.pde adapted by George Profenza 26 | // Import OSC 27 | import oscP5.*; 28 | // import Runway library 29 | import com.runwayml.*; 30 | // reference to runway instance 31 | RunwayOSC runway; 32 | 33 | // The caption to send 34 | String data = "{ \"caption\": \"a blue ocean\"}"; 35 | 36 | void setup() { 37 | size(400, 350); 38 | frameRate(25); 39 | // setup Runway 40 | runway = new RunwayOSC(this); 41 | } 42 | 43 | void draw() { 44 | background(0); 45 | text("press 's' to send text to Runway",5,15); 46 | } 47 | 48 | void keyPressed() { 49 | if(key == 's'){ 50 | runway.query(data); 51 | } 52 | } 53 | -------------------------------------------------------------------------------- /examples/OSC/face_landmarks/face_landmarks.pde: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2018 Runway AI Examples 2 | // 3 | // This file is part of Runway AI Examples. 4 | // 5 | // Runway-Examples is free software: you can redistribute it and/or modify 6 | // it under the terms of the GNU General Public License as published by 7 | // the Free Software Foundation, either version 3 of the License, or 8 | // (at your option) any later version. 9 | // 10 | // Runway-Examples is distributed in the hope that it will be useful, 11 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | // GNU General Public License for more details. 14 | // 15 | // You should have received a copy of the GNU General Public License 16 | // along with RunwayML. If not, see . 17 | // 18 | // =========================================================================== 19 | 20 | // RUNWAY 21 | // www.runwayapp.ai 22 | 23 | // face_landmarks Demo: 24 | // Receive OSC messages from Runway 25 | // Running face_landmarks model 26 | // original example by Joel Matthys @jwmatthys, adapted by George Profenza 27 | // import OSC library 28 | import oscP5.*; 29 | // import Runway library 30 | import com.runwayml.*; 31 | // reference to runway instance 32 | RunwayOSC runway; 33 | 34 | // This array will hold all the humans detected 35 | JSONObject data; 36 | 37 | void setup(){ 38 | // match sketch size to default model camera setup 39 | size(600,400); 40 | fill(9,130,250); 41 | noStroke(); 42 | // setup Runway 43 | runway = new RunwayOSC(this); 44 | } 45 | 46 | void draw(){ 47 | background(0); 48 | // use the utiliy class to draw PoseNet parts 49 | if(data != null){ 50 | JSONArray landmarks = data.getJSONArray("points"); 51 | if (landmarks != null) 52 | { 53 | for (int k = 0; k < landmarks.size(); k++) { 54 | // Body parts are relative to width and weight of the input 55 | JSONArray point = landmarks.getJSONArray(k); 56 | float x = point.getFloat(0); 57 | float y = point.getFloat(1); 58 | ellipse(x * width, y * height, 10, 10); 59 | } 60 | } 61 | } 62 | } 63 | 64 | // this is called when new Runway data is available 65 | void runwayDataEvent(JSONObject runwayData){ 66 | // point the sketch data to the Runway incoming data 67 | data = runwayData; 68 | } 69 | -------------------------------------------------------------------------------- /examples/OSC/im2txt/im2txt.pde: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2020 RunwayML Examples 2 | // 3 | // This file is part of RunwayML Examples. 4 | // 5 | // Runway-Examples is free software: you can redistribute it and/or modify 6 | // it under the terms of the GNU General Public License as published by 7 | // the Free Software Foundation, either version 3 of the License, or 8 | // (at your option) any later version. 9 | // 10 | // Runway-Examples is distributed in the hope that it will be useful, 11 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | // GNU General Public License for more details. 14 | // 15 | // You should have received a copy of the GNU General Public License 16 | // along with RunwayML. If not, see . 17 | // 18 | // =========================================================================== 19 | 20 | // RUNWAYML 21 | // www.runwayml.com 22 | 23 | // im2txt Demo: 24 | // Receive OSC messages from Runway 25 | // Running im2txt model 26 | // Original example by Cris Valenzuela, Anastasis Germanidis, Gene Kogan, adapted by George Profenza 27 | 28 | // Import OSC 29 | import oscP5.*; 30 | // import Runway library 31 | import com.runwayml.*; 32 | // reference to runway instance 33 | RunwayOSC runway; 34 | 35 | // The data coming in from Runway as a JSON Object {} 36 | JSONObject data; 37 | 38 | void setup() { 39 | size(500, 300); 40 | frameRate(25); 41 | fill(255); 42 | stroke(255); 43 | // setup Runway 44 | runway = new RunwayOSC(this); 45 | } 46 | 47 | void draw() { 48 | background(0); 49 | 50 | // Display captions 51 | drawCaptions(); 52 | } 53 | 54 | 55 | // A function to display the captions 56 | void drawCaptions() { 57 | // Only if there are any captions 58 | if (data != null) { 59 | String results = data.getString("caption"); 60 | text(results, 100, 100); 61 | } 62 | } 63 | 64 | // this is called when new Runway data is available 65 | void runwayDataEvent(JSONObject runwayData){ 66 | // point the sketch data to the Runway incoming data 67 | data = runwayData; 68 | } 69 | -------------------------------------------------------------------------------- /examples/OSC/im2txtWebcam/im2txtWebcam.pde: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2020 RunwayML Examples 2 | // 3 | // This file is part of RunwayML Examples. 4 | // 5 | // Runway-Examples is free software: you can redistribute it and/or modify 6 | // it under the terms of the GNU General Public License as published by 7 | // the Free Software Foundation, either version 3 of the License, or 8 | // (at your option) any later version. 9 | // 10 | // Runway-Examples is distributed in the hope that it will be useful, 11 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | // GNU General Public License for more details. 14 | // 15 | // You should have received a copy of the GNU General Public License 16 | // along with RunwayML. If not, see . 17 | // 18 | // =========================================================================== 19 | 20 | // RUNWAYML 21 | // www.runwayml.com 22 | 23 | // im2txt Demo: 24 | // Receive HTTP messages from Runway 25 | // Running im2txt model 26 | // Original example by Cris Valenzuela, Anastasis Germanidis, Gene Kogan, adapted by George Profenza 27 | 28 | // import OSC 29 | import oscP5.*; 30 | // import video library 31 | import processing.video.*; 32 | // import Runway library 33 | import com.runwayml.*; 34 | // reference to runway instance 35 | RunwayOSC runway; 36 | 37 | // The data coming in from Runway as a JSON Object {} 38 | JSONObject data; 39 | 40 | // reference to the camera 41 | Capture camera; 42 | 43 | // periocally to be updated using millis() 44 | int lastMillis; 45 | // how often should the above be updated and a time action take place ? 46 | // takes about 2-25s (2000-2500ms) for Runway to process a 600x400 im2txt frame on an older CPU 47 | int waitTime = 2500; 48 | 49 | void setup() { 50 | size(600, 400); 51 | frameRate(3); 52 | fill(255); 53 | stroke(255); 54 | // setup Runway 55 | runway = new RunwayOSC(this); 56 | // setup camera 57 | camera = new Capture(this,640,480); 58 | camera.start(); 59 | // setup timer 60 | lastMillis = millis(); 61 | } 62 | 63 | void draw() { 64 | // update timer 65 | int currentMillis = millis(); 66 | // if the difference between current millis and last time we checked past the wait time 67 | if(currentMillis - lastMillis >= waitTime){ 68 | // call the timed function 69 | sendFrameToRunway(); 70 | // update lastMillis, preparing for another wait 71 | lastMillis = currentMillis; 72 | } 73 | background(0); 74 | // draw webcam image 75 | image(camera,0,0); 76 | 77 | // Display captions 78 | drawCaptions(); 79 | } 80 | 81 | 82 | // A function to display the captions 83 | void drawCaptions() { 84 | // Only if there are any captions 85 | if (data != null) { 86 | String results = data.getString("caption"); 87 | text(results, 100, 100); 88 | } 89 | } 90 | 91 | void sendFrameToRunway(){ 92 | // nothing to send if there's no new camera data available 93 | if(camera.available() == false){ 94 | return; 95 | } 96 | // read a new frame 97 | camera.read(); 98 | // crop image to Runway input format (600x400) 99 | PImage image = camera.get(0,0,600,400); 100 | // query Runway with webcam image 101 | runway.query(image); 102 | } 103 | 104 | // this is called when new Runway data is available 105 | void runwayDataEvent(JSONObject runwayData){ 106 | // point the sketch data to the Runway incoming data 107 | data = runwayData; 108 | } 109 | -------------------------------------------------------------------------------- /examples/README: -------------------------------------------------------------------------------- 1 | add examples for your Library here. -------------------------------------------------------------------------------- /examples/Xtra/attnGANAndroid/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | -------------------------------------------------------------------------------- /examples/Xtra/attnGANAndroid/attnGANAndroid.pde: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2020 Runway ML Examples 2 | // 3 | // This file is part of Runway ML Examples. 4 | // 5 | // Runway-Examples is free software: you can redistribute it and/or modify 6 | // it under the terms of the GNU General Public License as published by 7 | // the Free Software Foundation, either version 3 of the License, or 8 | // (at your option) any later version. 9 | // 10 | // Runway-Examples is distributed in the hope that it will be useful, 11 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | // GNU General Public License for more details. 14 | // 15 | // You should have received a copy of the GNU General Public License 16 | // along with RunwayML. If not, see . 17 | // 18 | // =========================================================================== 19 | 20 | // RUNWAYML 21 | // www.runwayml.com 22 | 23 | // AttnGAN Demo 24 | // Send OSC text messages to Runway and generate images 25 | // example based on https://github.com/runwayml/processing/blob/master/attnGAN/attnGAN.pde adapted by George Profenza 26 | // import Runway library 27 | import com.runwayml.*; 28 | // reference to runway instance 29 | RunwayHTTP runway; 30 | 31 | // result image will be stored here 32 | PImage runwayResult; 33 | 34 | // IP of the computer running RunwayML: change this to your local network configuration 35 | String RUNWAYML_HTTP_IP = "192.168.0.24"; 36 | // HTTP port: default is 8000, however this increments when running multiple models (e.g. in chained mode) 37 | int RUNWAYML_HTTP_PORT = 8000; 38 | 39 | int captionIndex = 0; 40 | String[] captions = {"cup cake","donut","eclair","froyo","gingerbread","honeycomb","ice cream sandwich","jelly bean","KitKat","lollipop","marshmallow","nougat","oreo","pie"}; 41 | // The caption to send 42 | JSONObject input = new JSONObject(); 43 | 44 | void setup() { 45 | size(1024, 1024); 46 | textSize(90); 47 | frameRate(25); 48 | // setup Runway 49 | runway = new RunwayHTTP(this,RUNWAYML_HTTP_IP,RUNWAYML_HTTP_PORT); 50 | // don't send messages to Runway continuously 51 | runway.setAutoUpdate(false); 52 | // update caption JSON to send to Runway 53 | updateCaption(); 54 | } 55 | 56 | // iterate through the array of words and update the JSON input for Runway 57 | void updateCaption(){ 58 | input.setString("caption",captions[captionIndex]); 59 | // increment caption index 60 | captionIndex++; 61 | // reset back to 0 at the end of array 62 | if(captionIndex >= captions.length){ 63 | captionIndex = 0; 64 | } 65 | } 66 | 67 | void draw() { 68 | background(0); 69 | 70 | if(runwayResult != null){ 71 | image(runwayResult,0,0,width,height); 72 | } 73 | text("tap screen to to send text to Runway\n"+input,3,90); 74 | } 75 | 76 | void mouseReleased() { 77 | // visual feedback as request is sent 78 | fill(30); 79 | // send data 80 | runway.query(input.toString()); 81 | } 82 | 83 | // this is called when new Runway data is available 84 | void runwayDataEvent(JSONObject runwayData){ 85 | // visual feedback as data arrives 86 | fill(255); 87 | String base64ImageString = runwayData.getString("result"); 88 | // try to decode the image from 89 | try{ 90 | PImage result = ModelUtilsAndroid.fromBase64(base64ImageString); 91 | if(result != null){ 92 | runwayResult = result; 93 | } 94 | }catch(Exception e){ 95 | e.printStackTrace(); 96 | } 97 | // update text to send on next tap 98 | updateCaption(); 99 | } 100 | -------------------------------------------------------------------------------- /examples/Xtra/attnGANAndroid/code/sketch.properties: -------------------------------------------------------------------------------- 1 | mode=Android 2 | component=app 3 | mode.id=processing.mode.android.AndroidMode 4 | -------------------------------------------------------------------------------- /examples/Xtra/attnGANAndroid/sketch.properties: -------------------------------------------------------------------------------- 1 | mode=Android 2 | mode.id=processing.mode.android.AndroidMode 3 | -------------------------------------------------------------------------------- /examples/Xtra/attnGANPromptRaspberryPiZero/attnGANPromptRaspberryPiZero.pde: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2020 Runway ML Examples 2 | // 3 | // This file is part of Runway ML Examples. 4 | // 5 | // Runway-Examples is free software: you can redistribute it and/or modify 6 | // it under the terms of the GNU General Public License as published by 7 | // the Free Software Foundation, either version 3 of the License, or 8 | // (at your option) any later version. 9 | // 10 | // Runway-Examples is distributed in the hope that it will be useful, 11 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | // GNU General Public License for more details. 14 | // 15 | // You should have received a copy of the GNU General Public License 16 | // along with RunwayML. If not, see . 17 | // 18 | // =========================================================================== 19 | 20 | // RUNWAYML 21 | // www.runwayml.com 22 | 23 | // AttnGAN Demo 24 | // Send OSC text messages to Runway and generate images 25 | // example based on https://github.com/runwayml/processing/blob/master/attnGAN/attnGAN.pde adapted by George Profenza 26 | 27 | // import Runway library 28 | import com.runwayml.*; 29 | // reference to runway instance 30 | RunwayHTTP runway; 31 | 32 | // result image will be stored here 33 | PImage runwayResult; 34 | 35 | // IP of the computer running RunwayML: change this to your local network configuration 36 | String RUNWAYML_HTTP_IP = "192.168.0.24"; 37 | // HTTP port: default is 8000, however this increments when running multiple models (e.g. in chained mode) 38 | int RUNWAYML_HTTP_PORT = 8000; 39 | 40 | void setup() { 41 | size(256, 256); 42 | frameRate(25); 43 | // setup Runway 44 | runway = new RunwayHTTP(this,RUNWAYML_HTTP_IP,RUNWAYML_HTTP_PORT); 45 | // don't send messages to Runway continuously 46 | runway.setAutoUpdate(false); 47 | } 48 | 49 | void draw() { 50 | background(0); 51 | if(runwayResult != null){ 52 | image(runwayResult,0,0); 53 | } 54 | text("press 's' to send text to Runway",5,15); 55 | } 56 | 57 | void keyPressed() { 58 | if(key == 's'){ 59 | String caption = (String)javax.swing.JOptionPane.showInputDialog(frame, "Text", "AttnGAN Input Text", javax.swing.JOptionPane.PLAIN_MESSAGE); 60 | if(caption != null){ 61 | runway.query("{ \"caption\": \""+ caption +"\"}"); 62 | } 63 | } 64 | } 65 | 66 | // this is called when new Runway data is available 67 | void runwayDataEvent(JSONObject runwayData){ 68 | // point the sketch data to the Runway incoming data 69 | String base64ImageString = runwayData.getString("result"); 70 | // try to decode the image from 71 | try{ 72 | PImage result = ModelUtils.fromBase64(base64ImageString); 73 | if(result != null){ 74 | runwayResult = result; 75 | } 76 | }catch(Exception e){ 77 | e.printStackTrace(); 78 | } 79 | } 80 | -------------------------------------------------------------------------------- /examples/Xtra/attnGANPromptRaspberryPiZero/code/sketch.properties: -------------------------------------------------------------------------------- 1 | mode=Java 2 | component=app 3 | mode.id=processing.mode.java.JavaMode 4 | -------------------------------------------------------------------------------- /lib/README: -------------------------------------------------------------------------------- 1 | The lib folder: 2 | In case your Library requires 3rd party libraries, which need to be 3 | added to the distribution, put them into the lib folder. 4 | These 3rd party libraries will be added to your distribution and are 5 | located next to your Library's jar file. 6 | This does not apply to .jar files that are considered core processing libraries. -------------------------------------------------------------------------------- /lib/okhttp.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/runwayml/processing-library/ee3d79601e3539d68e43979f3b0cf4fe0d812f7c/lib/okhttp.jar -------------------------------------------------------------------------------- /lib/okio.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/runwayml/processing-library/ee3d79601e3539d68e43979f3b0cf4fe0d812f7c/lib/okio.jar -------------------------------------------------------------------------------- /license.txt: -------------------------------------------------------------------------------- 1 | A template to build a Library for the Processing programming environment. 2 | 3 | Part of the Processing project - http://processing.org 4 | 5 | Copyright 2011-2018 Elie Zananiri 6 | Copyright 2008-2011 Andreas Shlegel 7 | 8 | Licensed under the Apache License, Version 2.0 (the "License"); 9 | you may not use this file except in compliance with the License. 10 | You may obtain a copy of the License at 11 | 12 | http://www.apache.org/licenses/LICENSE-2.0 13 | 14 | Unless required by applicable law or agreed to in writing, software 15 | distributed under the License is distributed on an "AS IS" BASIS, 16 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 17 | See the License for the specific language governing permissions and 18 | limitations under the License. -------------------------------------------------------------------------------- /resources/README.md: -------------------------------------------------------------------------------- 1 | ## How to install ##library.name## 2 | 3 | ### Install with the Contribution Manager 4 | 5 | Add contributed Libraries by selecting the menu item _Sketch_ → _Import Library..._ → _Add Library..._ This will open the Contribution Manager, where you can browse for ##library.name##, or any other Library you want to install. 6 | 7 | Not all available Libraries have been converted to show up in this menu. If a Library isn't there, it will need to be installed manually by following the instructions below. 8 | 9 | ### Manual Install 10 | 11 | Contributed Libraries may be downloaded separately and manually placed within the `libraries` folder of your Processing sketchbook. To find (and change) the Processing sketchbook location on your computer, open the Preferences window from the Processing application (PDE) and look for the "Sketchbook location" item at the top. 12 | 13 | By default the following locations are used for your sketchbook folder: 14 | * For Mac users, the sketchbook folder is located inside `~/Documents/Processing` 15 | * For Windows users, the sketchbook folder is located inside `My Documents/Processing` 16 | 17 | Download ##library.name## from ##library.url## 18 | 19 | Unzip and copy the contributed Library's folder into the `libraries` folder in the Processing sketchbook. You will need to create this `libraries` folder if it does not exist. 20 | 21 | The folder structure for Library ##library.name## should be as follows: 22 | 23 | ``` 24 | Processing 25 | libraries 26 | ##library.name## 27 | examples 28 | library 29 | ##library.name##.jar 30 | reference 31 | src 32 | ``` 33 | 34 | Some folders like `examples` or `src` might be missing. After Library ##library.name## has been successfully installed, restart the Processing application. 35 | 36 | ### Troubleshooting 37 | 38 | If you're having trouble, have a look at the [Processing Wiki](https://github.com/processing/processing/wiki/How-to-Install-a-Contributed-Library) for more information, or contact the author [##author.name##](##author.url##). 39 | -------------------------------------------------------------------------------- /resources/code/ExampleTaglet.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/runwayml/processing-library/ee3d79601e3539d68e43979f3b0cf4fe0d812f7c/resources/code/ExampleTaglet.class -------------------------------------------------------------------------------- /resources/code/ant-contrib-1.0b3.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/runwayml/processing-library/ee3d79601e3539d68e43979f3b0cf4fe0d812f7c/resources/code/ant-contrib-1.0b3.jar -------------------------------------------------------------------------------- /resources/library.properties: -------------------------------------------------------------------------------- 1 | # More on this file here: https://github.com/processing/processing/wiki/Library-Basics 2 | # UTF-8 supported. 3 | 4 | # The name of your Library as you want it formatted. 5 | name = ##library.name## 6 | 7 | # List of authors. Links can be provided using the syntax [author name](url). 8 | authors = [##author.name##](##author.url##) 9 | 10 | # A web page for your Library, NOT a direct link to where to download it. 11 | url = ##library.url## 12 | 13 | # The category (or categories) of your Library, must be from the following list: 14 | # "3D" "Animation" "Compilations" "Data" 15 | # "Fabrication" "Geometry" "GUI" "Hardware" 16 | # "I/O" "Language" "Math" "Simulation" 17 | # "Sound" "Utilities" "Typography" "Video & Vision" 18 | # 19 | # If a value other than those listed is used, your Library will listed as 20 | # "Other". Many categories must be comma-separated. 21 | categories = ##library.categories## 22 | 23 | # A short sentence (or fragment) to summarize the Library's function. This will 24 | # be shown from inside the PDE when the Library is being installed. Avoid 25 | # repeating the name of your Library here. Also, avoid saying anything redundant 26 | # like mentioning that it's a Library. This should start with a capitalized 27 | # letter, and end with a period. 28 | sentence = ##library.sentence## 29 | 30 | # Additional information suitable for the Processing website. The value of 31 | # 'sentence' always will be prepended, so you should start by writing the 32 | # second sentence here. If your Library only works on certain operating systems, 33 | # mention it here. 34 | paragraph = ##library.paragraph## 35 | 36 | # Links in the 'sentence' and 'paragraph' attributes can be inserted using the 37 | # same syntax as for authors. 38 | # That is, [here is a link to Processing](http://processing.org/) 39 | 40 | # A version number that increments once with each release. This is used to 41 | # compare different versions of the same Library, and check if an update is 42 | # available. You should think of it as a counter, counting the total number of 43 | # releases you've had. 44 | version = ##library.version## # This must be parsable as an int 45 | 46 | # The version as the user will see it. If blank, the version attribute will be 47 | # used here. This should be a single word, with no spaces. 48 | prettyVersion = ##library.prettyVersion## # This is treated as a String 49 | 50 | # The min and max revision of Processing compatible with your Library. 51 | # Note that these fields use the revision and not the version of Processing, 52 | # parsable as an int. For example, the revision number for 2.2.1 is 227. 53 | # You can find the revision numbers in the change log: https://raw.githubusercontent.com/processing/processing/master/build/shared/revisions.txt 54 | # Only use maxRevision (or minRevision), when your Library is known to 55 | # break in a later (or earlier) release. Otherwise, use the default value 0. 56 | minRevision = ##compatible.minRevision## 57 | maxRevision = ##compatible.maxRevision## 58 | -------------------------------------------------------------------------------- /web/stylesheet.css: -------------------------------------------------------------------------------- 1 | /* processingLibs style by andreas schlegel, sojamo. */ 2 | 3 | 4 | * { 5 | margin:0; 6 | padding:0; 7 | border:0; 8 | } 9 | 10 | 11 | body { 12 | font-family : Verdana, Geneva, Arial, Helvetica, sans-serif; 13 | font-size : 100%; 14 | font-size : 0.70em; 15 | font-weight : normal; 16 | line-height : normal; 17 | } 18 | 19 | 20 | 21 | #container { 22 | margin-left:64px; 23 | background-color:#fff; 24 | } 25 | 26 | #header { 27 | float:left; 28 | padding-top:24px; 29 | padding-bottom:48px; 30 | } 31 | 32 | #menu { 33 | margin-top:16px; 34 | float:left; 35 | margin-bottom:64px; 36 | } 37 | 38 | 39 | #about, 40 | #download, 41 | #examples, 42 | #demos, 43 | #misc { 44 | width:480px; 45 | float:left; 46 | margin-right:24px; 47 | } 48 | 49 | 50 | #resources, #info { 51 | width:320px; 52 | float:left; 53 | } 54 | 55 | 56 | .clear { 57 | clear:both; 58 | } 59 | 60 | #footer { 61 | margin-top:300px; 62 | height:20px; 63 | margin-bottom:32px; 64 | } 65 | 66 | 67 | ul { 68 | list-style:none; 69 | padding:0; 70 | margin:0; 71 | } 72 | 73 | 74 | #menu ul li, #subMenu ul li { 75 | float:left; 76 | padding-right:6px; 77 | } 78 | 79 | 80 | 81 | 82 | 83 | 84 | /* Headings */ 85 | 86 | h1 { 87 | font-size:2em; 88 | font-weight:normal; 89 | } 90 | 91 | 92 | h2, h3, h4, h5, th { 93 | font-size:1.3em; 94 | font-weight:normal; 95 | margin-bottom:4px; 96 | } 97 | 98 | 99 | 100 | p { 101 | font-size:1em; 102 | width:90%; 103 | margin-bottom:32px; 104 | } 105 | 106 | 107 | pre, code { 108 | font-family:"Courier New", Courier, monospace; 109 | font-size:1em; 110 | line-height:normal; 111 | } 112 | 113 | 114 | 115 | 116 | hr { 117 | border:0; 118 | height:1px; 119 | margin-bottom:24px; 120 | } 121 | 122 | 123 | a { 124 | text-decoration: underline; 125 | font-weight: normal; 126 | } 127 | 128 | 129 | a:hover, 130 | a:active { 131 | text-decoration: underline; 132 | font-weight: normal; 133 | } 134 | 135 | 136 | a:visited, 137 | a:link:visited { 138 | text-decoration: underline; 139 | font-weight: normal; 140 | } 141 | 142 | 143 | 144 | img { 145 | border: 0px solid #000000; 146 | } 147 | 148 | 149 | 150 | 151 | 152 | /* COLORS */ 153 | 154 | 155 | body { 156 | color : #333; 157 | background-color :#fff; 158 | } 159 | 160 | 161 | #header { 162 | background-color:#fff; 163 | color:#333; 164 | } 165 | 166 | 167 | 168 | h1, h2, h3, h4, h5, h6 { 169 | color:#666; 170 | } 171 | 172 | 173 | pre, code { 174 | color: #000000; 175 | } 176 | 177 | 178 | a,strong { 179 | color: #333; 180 | } 181 | 182 | 183 | a:hover, 184 | a:active { 185 | color: #333; 186 | } 187 | 188 | 189 | a:visited, 190 | a:link:visited { 191 | color: #333; 192 | } 193 | 194 | 195 | #footer, #menu { 196 | background-color:#fff; 197 | color:#333; 198 | } 199 | 200 | 201 | #footer a, #menu a { 202 | color:#333; 203 | } 204 | --------------------------------------------------------------------------------