Skip to content
Permalink
Browse files

Not hosting

  • Loading branch information...
s32x committed Apr 6, 2019
1 parent 7c62db5 commit e146859df66ef46ab08cfb05183ba4130d204c33
Showing with 32 additions and 25 deletions.
  1. +6 −14 Makefile
  2. +8 −3 README.md
  3. +1 −1 classifier/classify.go
  4. +1 −1 go.mod
  5. +10 −2 go.sum
  6. +6 −4 service/demo.go
  7. BIN tf/.DS_Store
@@ -1,21 +1,13 @@
init:
-rm -rf vendor
-rm -f go.mod
-rm -f go.sum
go clean
-rm -rf ./vendor go.mod go.sum
GO111MODULE=on go mod init

deps:
-rm -rf vendor
-rm -f go.sum
-rm -rf ./vendor go.sum
GO111MODULE=on go mod vendor

test:
go test ./...
install:
make deps
go install

run:
DEMO=true go run main.go
push:
make deps
docker build --no-cache -t s32x/gamedetect .
docker push s32x/gamedetect
DEMO=true go run main.go
@@ -10,12 +10,17 @@ gamedetect is a simple API that uses a trained neural network to identify games

## Try this...

Send a POST request with a (relatively clear) game screenshot (one in the supported list) in the "image" field of a form to gamedetect.io.
Start a container with the gamedetect API running by running

For example:
```bash
docker run -e DEMO=true -p 8080:8080 s32x/gamedetect
```
(Navigating to `http://localhost:8080` will provide a visual demonstration)

Then, send a POST request with a (relatively clear) game screenshot (one in the supported list) in the "image" field of a form to localhost:8080.

```bash
curl -X POST https://gamedetect.io -F image=@MY_GAME_SCREENSHOT.png
curl -X POST http://localhost:8080 -F image=@MY_GAME_SCREENSHOT.png
```

Excited yet? I sure am! gamedetect is a fun project I've been playing with in my free time to learn about Computer Vision, Neural Networks, and Tensorflow. It's sort of my own hello world app that also could potentially serve a real use-case on Twitch or any other streaming platform that requires broadcasters to categorize their stream. That being said, I'm still very much a beginner to all of this and I'm sure I'm doing a number of things wrong - feel free to let me know in the issues if you'd like.
@@ -56,7 +56,7 @@ func (c *Classifier) ClassifyMultipart(fh *multipart.FileHeader) ([]Prediction,
return c.ClassifyBytes(buf.Bytes(), fn[len(fn)-1])
}

// ClassifyBytes classifies a passed images bytes and returns the predictions
// ClassifyBytes classifies the passed images bytes and returns the predictions
// as a slice of Predictions
func (c *Classifier) ClassifyBytes(img []byte, ext string) ([]Prediction, error) {
// Create the scope and the input/output operations for normalization
2 go.mod
@@ -4,5 +4,5 @@ go 1.12

require (
github.com/labstack/echo/v4 v4.0.1-0.20190313005416-e3717be4beda
github.com/tensorflow/tensorflow v1.9.0-rc2.0.20190331021011-c6b4b2c791a3
github.com/tensorflow/tensorflow v1.9.0-rc2.0.20190406091552-378f773e9a8f
)
12 go.sum
@@ -1,16 +1,24 @@
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/dgrijalva/jwt-go v3.2.0+incompatible h1:7qlOGliEKZXTDg6OTjfoBKDXWrumCAMpl/TFQ4/5kLM=
github.com/dgrijalva/jwt-go v3.2.0+incompatible/go.mod h1:E3ru+11k8xSBh+hMPgOLZmtrrCbhqsmaPHjLKYnJCaQ=
github.com/labstack/echo/v4 v4.0.1-0.20190313005416-e3717be4beda h1:jdIL1o6i2sCWMsnCrShsiuEW0vmMA4Lz8V+zJ0nPDD0=
github.com/labstack/echo/v4 v4.0.1-0.20190313005416-e3717be4beda/go.mod h1:tZv7nai5buKSg5h/8E6zz4LsD/Dqh9/91Mvs7Z5Zyno=
github.com/labstack/gommon v0.2.8 h1:JvRqmeZcfrHC5u6uVleB4NxxNbzx6gpbJiQknDbKQu0=
github.com/labstack/gommon v0.2.8/go.mod h1:/tj9csK2iPSBvn+3NLM9e52usepMtrd5ilFYA+wQNJ4=
github.com/mattn/go-colorable v0.0.9 h1:UVL0vNpWh04HeJXV0KLcaT7r06gOH2l4OW6ddYRUIY4=
github.com/mattn/go-colorable v0.0.9/go.mod h1:9vuHe8Xs5qXnSaW/c/ABM9alt+Vo+STaOChaDxuIBZU=
github.com/mattn/go-isatty v0.0.4 h1:bnP0vzxcAdeI1zdubAl5PjU6zsERjGZb7raWodagDYs=
github.com/mattn/go-isatty v0.0.4/go.mod h1:M+lRXTBqGeGNdLjl/ufCoiOlB5xdOkqRJdNxMWT7Zi4=
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI=
github.com/tensorflow/tensorflow v1.9.0-rc2.0.20190331021011-c6b4b2c791a3 h1:D+hFI28vR8VLKDTlfZDnRzumBj8iCw7dvNra0ReO9+I=
github.com/tensorflow/tensorflow v1.9.0-rc2.0.20190331021011-c6b4b2c791a3/go.mod h1:itOSERT4trABok4UOoG+X4BoKds9F3rIsySdn+Lvu90=
github.com/tensorflow/tensorflow v1.9.0-rc2.0.20190406091552-378f773e9a8f h1:g8zlX6SGaLy8TVwC49LseQi28LRF6l6QHBqSUxhXKUw=
github.com/tensorflow/tensorflow v1.9.0-rc2.0.20190406091552-378f773e9a8f/go.mod h1:itOSERT4trABok4UOoG+X4BoKds9F3rIsySdn+Lvu90=
github.com/valyala/bytebufferpool v1.0.0 h1:GqA5TC/0021Y/b9FG4Oi9Mr3q7XYx6KllzawFIhcdPw=
github.com/valyala/bytebufferpool v1.0.0/go.mod h1:6bBcMArwyJ5K/AmCkWv1jt77kVWyCJ6HpOuEn7z0Csc=
github.com/valyala/fasttemplate v0.0.0-20170224212429-dcecefd839c4 h1:gKMu1Bf6QINDnvyZuTaACm9ofY+PRh+5vFz4oxBZeF8=
github.com/valyala/fasttemplate v0.0.0-20170224212429-dcecefd839c4/go.mod h1:50wTf68f99/Zt14pr046Tgt3Lp2vLyFZKzbFXTOabXw=
golang.org/x/crypto v0.0.0-20190130090550-b01c7a725664 h1:YbZJ76lQ1BqNhVe7dKTSB67wDrc2VPRR75IyGyyPDX8=
golang.org/x/crypto v0.0.0-20190130090550-b01c7a725664/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4=
golang.org/x/sys v0.0.0-20190129075346-302c3dd5f1cc h1:WiYx1rIFmx8c0mXAFtv5D/mHyKe1+jmuP7PViuwqwuQ=
golang.org/x/sys v0.0.0-20190129075346-302c3dd5f1cc/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
@@ -75,11 +75,13 @@ func Demo(tr *TestResults, classifier *classifier.Classifier) echo.HandlerFunc {
}
}

// ProcessTestData pre-processes all the test data in the passed testDir, returning
// the results for serving on the demos index
func ProcessTestData(classifier *classifier.Classifier, testDir string) (*TestResults, error) {
// ProcessTestData pre-processes all the test data in the passed testDir,
// returning the results for serving on the demos index
func ProcessTestData(classifier *classifier.Classifier,
testDir string) (*TestResults, error) {
tr := &TestResults{}
if err := filepath.Walk(testDir, func(path string, fi os.FileInfo, err error) error {
if err := filepath.Walk(testDir, func(path string, fi os.FileInfo,
err error) error {
// If there's an error reading the file or it's a directory, return
filename := fi.Name()
if err != nil || fi.IsDir() || filename == ".DS_Store" {
BIN +6 KB tf/.DS_Store
Binary file not shown.

0 comments on commit e146859

Please sign in to comment.
You can’t perform that action at this time.