Created
February 27, 2017 00:32
-
-
Save unixpickle/21cdbdbb6d63af645d9ec88f691edba7 to your computer and use it in GitHub Desktop.
Training image test
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Quickly hand-verify inputs to my ResNet | |
package main | |
import ( | |
"image" | |
"image/color" | |
"image/png" | |
"math/rand" | |
"os" | |
"time" | |
"github.com/unixpickle/imagenet" | |
) | |
func main() { | |
rand.Seed(time.Now().UnixNano()) | |
aug, _ := imagenet.TrainingImage("monkey.jpg") | |
augVec := aug.Data().([]float32) | |
if len(augVec) != 224*224*3 { | |
panic("length") | |
} | |
res := image.NewRGBA(image.Rect(0, 0, 224, 224)) | |
for y := 0; y < 224; y++ { | |
for x := 0; x < 224; x++ { | |
rgb := augVec[:3] | |
augVec = augVec[3:] | |
res.SetRGBA(x, y, color.RGBA{ | |
R: uint8(rgb[0]*0xff + 0.5), | |
G: uint8(rgb[1]*0xff + 0.5), | |
B: uint8(rgb[2]*0xff + 0.5), | |
A: 0xff, | |
}) | |
} | |
} | |
f, _ := os.Create("output.png") | |
png.Encode(f, res) | |
f.Close() | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment