Willenberg commited on
Commit
77ad637
·
1 Parent(s): 390de6f

Fixed merge

Browse files
Files changed (1) hide show
  1. app.py +0 -30
app.py CHANGED
@@ -1,4 +1,3 @@
1
- <<<<<<< HEAD
2
  import numpy as np
3
  import gradio as gr
4
  from PIL import Image
@@ -29,33 +28,4 @@ gr.Interface(fn=classify,
29
  inputs=input_sketchpad,
30
  outputs=output_lable,
31
  allow_flagging=False,
32
- =======
33
- import numpy as np
34
- import gradio as gr
35
- from PIL import Image
36
- from tensorflow import keras
37
-
38
- model = keras.models.Sequential([
39
- keras.layers.Flatten(input_shape=(28, 28)), # Diese Schicht nimmt unser 2D-Bild und verwandelt es in ein 1D-Array
40
- keras.layers.Dense(512, activation='relu'), # Als Nächstes kommen zwei Schichten mit 512 künstlichen Neuronen. Als Funktion wählen wir 'relu' f(x) = max(0,x)
41
- keras.layers.Dense(512, activation='relu'),
42
- keras.layers.Dense(10, activation='softmax') # Die letzte Schicht besteht aus 10 Neuronen, die für unsere 10 Zahlen stehen. Die 'softmax' Funktion wandelt die Ergebnisse der vorherigen Schicht in Wahrscheinlichkeiten
43
- ])
44
-
45
- model.compile(optimizer='adam', loss='sparse_categorical_crossentropy', metrics=['accuracy'])
46
-
47
- model.load_weights('./weights/weights')
48
-
49
- def classify(input):
50
- image = np.expand_dims(np.array(Image.fromarray(input['layers'][0]).resize((28,28),resample=Image.Resampling.BILINEAR), dtype=int), axis=0)#[:,:,0]
51
- prediction = model.predict(image).tolist()[0]
52
- return {str(i): float(prediction[i]) for i in range(10)}
53
-
54
- input_sketchpad = gr.Paint(image_mode="L", brush=gr.components.image_editor.Brush(default_color="rgb(156, 104, 200)"))
55
-
56
- gr.Interface(fn=classify,
57
- inputs=input_sketchpad,
58
- outputs="label",
59
- allow_flagging=False,
60
- >>>>>>> 1f82054bee2ed11c23599ab720a05335eb2d9499
61
  theme=gr.themes.Soft()).launch()
 
 
1
  import numpy as np
2
  import gradio as gr
3
  from PIL import Image
 
28
  inputs=input_sketchpad,
29
  outputs=output_lable,
30
  allow_flagging=False,
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
31
  theme=gr.themes.Soft()).launch()