From fdba7094891cb52a7ff2683cdc805924a82428d8 Mon Sep 17 00:00:00 2001 From: Ali Abid Date: Thu, 2 Jul 2020 08:26:12 -0700 Subject: [PATCH] fix examples bug --- build/lib/gradio/interface.py | 13 ++-- dist/gradio-0.9.4-py3.7.egg | Bin 1778427 -> 1778449 bytes examples/__init__.py | 0 examples/imdb_interactive.py | 94 ------------------------ examples/imdb_saliency.py | 124 -------------------------------- examples/imdb_utils.py | 52 -------------- examples/mnist_interactive.py | 38 ---------- examples/mnist_saliency.py | 51 ------------- examples/mnist_saliency_only.py | 50 ------------- gradio/interface.py | 13 ++-- 10 files changed, 14 insertions(+), 421 deletions(-) delete mode 100644 examples/__init__.py delete mode 100644 examples/imdb_interactive.py delete mode 100644 examples/imdb_saliency.py delete mode 100644 examples/imdb_utils.py delete mode 100644 examples/mnist_interactive.py delete mode 100644 examples/mnist_saliency.py delete mode 100644 examples/mnist_saliency_only.py diff --git a/build/lib/gradio/interface.py b/build/lib/gradio/interface.py index 22a10db5ba..7fee814d6a 100644 --- a/build/lib/gradio/interface.py +++ b/build/lib/gradio/interface.py @@ -307,13 +307,14 @@ class Interface: config["share_url"] = share_url processed_examples = [] - for example_set in self.examples: - processed_set = [] - for iface, example in zip(self.input_interfaces, example_set): - processed_set.append(iface.process_example(example)) - processed_examples.append(processed_set) + if self.examples is not None: + for example_set in self.examples: + processed_set = [] + for iface, example in zip(self.input_interfaces, example_set): + processed_set.append(iface.process_example(example)) + processed_examples.append(processed_set) + config["examples"] = processed_examples - config["examples"] = processed_examples networking.set_config(config, output_directory) return httpd, path_to_local_server, share_url diff --git a/dist/gradio-0.9.4-py3.7.egg b/dist/gradio-0.9.4-py3.7.egg index bc04934cdff06dda340f8dfdb9cbedb77b9fc770..a30cb41e6bd58e1d93a1fe43805b429e5f9444e9 100644 GIT binary patch delta 9449 zcmY+K1yof{*T?U@bax)QTe?Az25F>0QWQby61)NuO6Q?lx*H?}Nohnvx)CX*L-;Q8 ze$V^7cdh@L*}s|Dvu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Pz?cO{|tUW z0J%SX2tWZv$p0P}gHbR*53&Q!zyLXj6G({)NJAMN($pO2z+hB>0|Em}kO;C3uAl<4 z5KfQ@4Pd{m1!|!I0Q99LD2EAgWF6f;llU4`{%3~-B3On*R`#+zXh&Zdi zpNU3nM);~(02OLyk~(nAb@hwk=4e%< z5JNr$4-5t6&i~v|9+brdME|6QVIotzcK@cn!~~fCq)xE<9#d^$pkM}JqwxPvDg^w6 z30OhgKy56*5Qe`%2+A!GQh}XV00%4@X{B5d5`)7Fg!mua0~}v1+|EYF+e&FI5t>{gM5|A;3piw7}m}S z2lqMQe4r^VGE zwBPYB!E-{A3?zXVgCB?iC1_OQt%Dq-BLPIA_NjlPJV^jShyz$e0;oba%KorSQa}QF z{{BB>T+osf;Dr`W{0nMtfy(y3;N}(_qJVHJfEZLDL%v@S_Scw)5o3YrWXQf)F#i%a zOkx6X<(9Z&{UxP-{oxyUvfYI8cgulXd@uT1Uqltr$o1e8Pp^u#sR4* zkc6A${|M&oGQt4EC;%>~JK0}6N&)aer78c3!3D5DE=r{Pkm@h_vz|<-0Rk|U5}<{= z1sf=lOFt4Mqyj9Uqg;Q3QmK%=6!ZKwkjn@gG@=LaK`4OChyxh_zy$h8@UOQ30ED0k zcmEpa0CF0hiQF2r;F1XPq0On09s7&^AHe{T>j(#IrAD^&TI|0tav5QQL^R0gaEbrI zJQ8qB(47VuT`75siNWM~3JmZ_l9&)grw8C*rW`Q=?ti|`HxWK^{}t6HM~n}W(;{oy z-1{$VNsC;p$InPX2s#-hSVN2amV87byR}$BTsq_e*QNPmQG*g@l8l_c>G_517DoI4J+# zGLM6j7<6Vp-ihKp)nD|I0g!+_TKLBrS)juEo6o=qP{CY}|KY}rfG8vkOlAZ$pg9*{ Y3L|npmM*BU!AnMf5dAF*fSic`2f-QW-T(jq diff --git a/examples/__init__.py b/examples/__init__.py deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/examples/imdb_interactive.py b/examples/imdb_interactive.py deleted file mode 100644 index 819b4b9d54..0000000000 --- a/examples/imdb_interactive.py +++ /dev/null @@ -1,94 +0,0 @@ -import tensorflow as tf -import sys -sys.path.insert(1, '../gradio') -import gradio -from tensorflow.keras.layers import * -from tensorflow.keras.datasets import imdb -import json - - -top_words = 5000 # Only keep the 5,000 most frequent words -max_word_length = 500 # The maximum length of the review should be 500 words (trim/pad otherwise) - -(X_train, y_train), (X_test, y_test) = imdb.load_data(num_words=top_words); -X_train = tf.keras.preprocessing.sequence.pad_sequences(X_train, maxlen=max_word_length) -X_test = tf.keras.preprocessing.sequence.pad_sequences(X_test, maxlen=max_word_length) - - -def get_trained_model(n): - model = tf.keras.models.Sequential() - model.add(Embedding(top_words, 32, input_length=max_word_length)) - model.add(Dropout(0.2)) - model.add(Conv1D(250, 3, padding='valid', activation='relu', strides=1)) - model.add(GlobalMaxPooling1D()) - model.add(Dense(250)) - model.add(Dropout(0.2)) - model.add(Activation('relu')) - model.add(Dense(1)) - model.add(Activation('sigmoid')) - model.compile(loss='binary_crossentropy', optimizer='adam', metrics=['accuracy']) - model.fit(X_train[:n], y_train[:n], epochs=2, batch_size=128) - print(model.evaluate(X_test, y_test)) - return model - - -model = get_trained_model(n=25000) - -# Gradio code # -NUM_SPECIAL_TOKENS = 3 -PAD_TOKEN = 0 -START_TOKEN = 1 -UNK_TOKEN = 2 - -word_to_id = tf.keras.datasets.imdb.get_word_index() -word_to_id = {k: (v + NUM_SPECIAL_TOKENS) for k, v in word_to_id.items()} - -id_to_word = {value: key for key, value in word_to_id.items()} -id_to_word[PAD_TOKEN] = "" # Padding tokens are converted to empty strings. -id_to_word[START_TOKEN] = "" # Start tokens are converted to empty strings. -id_to_word[UNK_TOKEN] = "UNK" # tokens are converted to "UNK". - - -def decode_vector_to_text(vector): - text = " ".join(id_to_word[id] for id in vector if id >= 2) - return text - - -def encode_text_to_vector(text, max_word_length=500, top_words=5000): - text_vector = text.split(" ") - encoded_vector = [ - word_to_id.get(element, UNK_TOKEN) if word_to_id.get(element, UNK_TOKEN) < top_words else UNK_TOKEN for element - in text_vector] - encoded_vector = [START_TOKEN] + encoded_vector - if len(encoded_vector) < max_word_length: - encoded_vector = (max_word_length - len(encoded_vector)) * [PAD_TOKEN] + encoded_vector - else: - encoded_vector = encoded_vector[:max_word_length] - return encoded_vector - - -def preprocessing(text): - new = encode_text_to_vector(text) - return tf.keras.preprocessing.sequence.pad_sequences([new], maxlen=max_word_length) - - -def postprocessing(pred): - if pred[0][0] > 0.5: - return json.dumps({"label": "Positive review"}) - else: - return json.dumps({"label": "Negative review"}) - - -textbox = gradio.inputs.Textbox(preprocessing_fn=preprocessing, - sample_inputs=[ - "A wonderful little production. The filming technique is very unassuming- very old-time-BBC fashion and gives a comforting, and sometimes discomforting, sense of realism to the entire piece. The actors are extremely well chosen- Michael Sheen not only has got all the polari but he has all the voices down pat too! You can truly see the seamless editing guided by the references to Williams' diary entries, not only is it well worth the watching but it is a terrificly written and performed piece. A masterful production about one of the great master's of comedy and his life. The realism really comes home with the little things: the fantasy of the guard which, rather than use the traditional 'dream' techniques remains solid then disappears.", - "This was a very brief episode that appeared in one of the Night Gallery show back in 1971. The episode starred Sue Lyon (of Lolita movie fame) and Joseph Campanella who play a baby sitter and a vampire, respectively. The vampire hires a baby sitter to watch his child (which appears to be some kind of werewolf or monster) while he goes out at night for blood. I don't know what purpose it was to make such an abbreviated episode that lasted just 5 minutes. They should just have expanded the earlier episode by those same 5 minutes and skipped this one. A total wasted effort.", - "No one expects the Star Trek movies to be high art, but the fans do expect a movie that is as good as some of the best episodes. Unfortunately, this movie had a muddled, implausible plot that just left me cringing - this is by far the worst of the nine (so far) movies. Even the chance to watch the well known characters interact in another movie can't save this movie - including the goofy scenes with Kirk, Spock and McCoy at Yosemite.I would say this movie is not worth a rental, and hardly worth watching, however for the True Fan who needs to see all the movies, renting this movie is about the only way you'll see it - even the cable channels avoid this movie.", - "This movie started out cringe-worthy--but it was meant to, with an overbearing mother, a witch of a rival, and a hesitant beauty queen constantly coming in second. There was some goofy overacting, and a few implausible plot points (She comes in second in EVERY single competition? ALL of them?) Unfortunately, the movie suffers horribly from it's need to, well, be a TV movie. Rather than end at the ending of the movie, an amusing twist in which the killer is (semi-plausibly) revealed, the movie continues for another twenty minutes, just to make sure that justice is done. Of course, now that the killer is revealed, she suddenly undergoes a complete personality shift--her character gets completely rewritten, because the writers don't need to keep her identity secret any more. The cheese completely sinks what otherwise could have been a passably amusing movie.", - "I thought this movie did a down right good job. It wasn't as creative or original as the first, but who was expecting it to be. It was a whole lotta fun. the more i think about it the more i like it, and when it comes out on DVD I'm going to pay the money for it very proudly, every last cent. Sharon Stone is great, she always is, even if her movie is horrible(Catwoman), but this movie isn't, this is one of those movies that will be underrated for its lifetime, and it will probably become a classic in like 20 yrs. Don't wait for it to be a classic, watch it now and enjoy it. Don't expect a masterpiece, or something thats gripping and soul touching, just allow yourself to get out of your life and get yourself involved in theirs.All in all, this movie is entertaining and i recommend people who haven't seen it see it.", - "I rented this movie, but I wasn't too sure what to expect of it. I was very glad to find that it's about the best Brazilian movie I've ever seen. The story is rather odd and simple, and above all, extremely original. We have Antonio, who is a young man living in Nordestina, a town in the middle of nowhere in the north east of Brazil, and who is deeply in love with Karina. The main conflict between the two is that, while Antonio loves his little town and has no wish to leave it, Karina wants to see the world and resents the place. As a prove of his love for her, he decides to go out himself and bring the world to her. He'll put Nordestina in the map, as he says. And the way he does it is unbelievable. This is a good movie; might be a bit stagy for some people due to its different editing job, but I think that it's also that that improves the story. It's just fun, and it makes you feel good."]) -label = gradio.outputs.Label(postprocessing_fn=postprocessing) -io = gradio.Interface(inputs=textbox, outputs=label, model_type="keras", model=model, always_flag=True) -httpd, path_to_local_server, share_url = io.launch(share=True, inbrowser=True) - -print("URL for IMDB model interface: ", share_url) diff --git a/examples/imdb_saliency.py b/examples/imdb_saliency.py deleted file mode 100644 index 62082778d8..0000000000 --- a/examples/imdb_saliency.py +++ /dev/null @@ -1,124 +0,0 @@ -import tensorflow as tf -import sys -sys.path.insert(1, '../gradio') -import gradio -from tensorflow.keras.layers import * -from tensorflow.keras.datasets import imdb -import json -from tensorflow.keras import backend as K -import numpy as np - - -top_words = 5000 # Only keep the 5,000 most frequent words -max_word_length = 500 # The maximum length of the review should be 500 words (trim/pad otherwise) - -(X_train, y_train), (X_test, y_test) = imdb.load_data(num_words=top_words); -X_train = tf.keras.preprocessing.sequence.pad_sequences(X_train, maxlen=max_word_length) -X_test = tf.keras.preprocessing.sequence.pad_sequences(X_test, maxlen=max_word_length) - - -def get_trained_model(n): - model = tf.keras.models.Sequential() - model.add(Embedding(top_words, 32, input_length=max_word_length)) - model.add(Dropout(0.2)) - model.add(Conv1D(250, 3, padding='valid', activation='relu', strides=1)) - model.add(GlobalMaxPooling1D()) - model.add(Dense(250)) - model.add(Dropout(0.2)) - model.add(Activation('relu')) - model.add(Dense(1)) - model.add(Activation('sigmoid')) - model.compile(loss='binary_crossentropy', optimizer='adam', metrics=['accuracy']) - model.fit(X_train[:n], y_train[:n], epochs=2, batch_size=128) - print(model.evaluate(X_test, y_test)) - return model - - -model = get_trained_model(n=25000) - -# Gradio code # -NUM_SPECIAL_TOKENS = 3 -PAD_TOKEN = 0 -START_TOKEN = 1 -UNK_TOKEN = 2 - -word_to_id = tf.keras.datasets.imdb.get_word_index() -word_to_id = {k: (v + NUM_SPECIAL_TOKENS) for k, v in word_to_id.items()} - -id_to_word = {value: key for key, value in word_to_id.items()} -id_to_word[PAD_TOKEN] = "" # Padding tokens are converted to empty strings. -id_to_word[START_TOKEN] = "" # Start tokens are converted to empty strings. -id_to_word[UNK_TOKEN] = "UNK" # tokens are converted to "UNK". - - -def decode_vector_to_text(vector): - text = " ".join(id_to_word[id] for id in vector if id >= 2) - return text - - -def encode_text_to_vector(text, max_word_length=500, top_words=5000): - text_vector = text.split(" ") - encoded_vector = [ - word_to_id.get(element, UNK_TOKEN) if word_to_id.get(element, UNK_TOKEN) < top_words else UNK_TOKEN for element - in text_vector] - encoded_vector = [START_TOKEN] + encoded_vector - if len(encoded_vector) < max_word_length: - encoded_vector = (max_word_length - len(encoded_vector)) * [PAD_TOKEN] + encoded_vector - else: - encoded_vector = encoded_vector[:max_word_length] - return encoded_vector - - -def preprocessing(text): - new = encode_text_to_vector(text) - return tf.keras.preprocessing.sequence.pad_sequences([new], maxlen=max_word_length) - - -def postprocessing(pred): - if pred[0][0] > 0.5: - return json.dumps({"label": "Positive review"}) - else: - return json.dumps({"label": "Negative review"}) - - -def saliency(interface, model, input, processed_input, output, processed_output): - with interface.graph.as_default(): - with interface.sess.as_default(): - output = output.argmax() - input_tensors = [model.layers[0].input, K.learning_phase()] - saliency_input = model.layers[1].input - saliency_output = model.layers[-1].output[:, output] - gradients = model.optimizer.get_gradients(saliency_output, saliency_input) - compute_gradients = K.function(inputs=input_tensors, outputs=gradients) - saliency_graph = compute_gradients(processed_input.reshape(1, 500))[0] - - saliency_graph = saliency_graph.reshape(500, 32) - - saliency_graph = np.abs(saliency_graph).sum(axis=1) - normalized_saliency = (saliency_graph - saliency_graph.min()) / \ - (saliency_graph.max() - saliency_graph.min()) - - start_idx = np.where(processed_input[0] == START_TOKEN)[0][0] - heat_map = [] - counter = 0 - words = input.split(" ") - for i in range(start_idx + 1, 500): - heat_map.extend([normalized_saliency[i]] * len(words[counter])) - heat_map.append(0) # zero saliency value assigned to the spaces between words - counter += 1 - return np.array(heat_map) - - -textbox = gradio.inputs.Textbox(preprocessing_fn=preprocessing, - sample_inputs=[ - "A wonderful little production. The filming technique is very unassuming- very old-time-BBC fashion and gives a comforting, and sometimes discomforting, sense of realism to the entire piece. The actors are extremely well chosen- Michael Sheen not only has got all the polari but he has all the voices down pat too! You can truly see the seamless editing guided by the references to Williams' diary entries, not only is it well worth the watching but it is a terrificly written and performed piece. A masterful production about one of the great master's of comedy and his life. The realism really comes home with the little things: the fantasy of the guard which, rather than use the traditional 'dream' techniques remains solid then disappears.", - "This was a very brief episode that appeared in one of the Night Gallery show back in 1971. The episode starred Sue Lyon (of Lolita movie fame) and Joseph Campanella who play a baby sitter and a vampire, respectively. The vampire hires a baby sitter to watch his child (which appears to be some kind of werewolf or monster) while he goes out at night for blood. I don't know what purpose it was to make such an abbreviated episode that lasted just 5 minutes. They should just have expanded the earlier episode by those same 5 minutes and skipped this one. A total wasted effort.", - "No one expects the Star Trek movies to be high art, but the fans do expect a movie that is as good as some of the best episodes. Unfortunately, this movie had a muddled, implausible plot that just left me cringing - this is by far the worst of the nine (so far) movies. Even the chance to watch the well known characters interact in another movie can't save this movie - including the goofy scenes with Kirk, Spock and McCoy at Yosemite.I would say this movie is not worth a rental, and hardly worth watching, however for the True Fan who needs to see all the movies, renting this movie is about the only way you'll see it - even the cable channels avoid this movie.", - "This movie started out cringe-worthy--but it was meant to, with an overbearing mother, a witch of a rival, and a hesitant beauty queen constantly coming in second. There was some goofy overacting, and a few implausible plot points (She comes in second in EVERY single competition? ALL of them?) Unfortunately, the movie suffers horribly from it's need to, well, be a TV movie. Rather than end at the ending of the movie, an amusing twist in which the killer is (semi-plausibly) revealed, the movie continues for another twenty minutes, just to make sure that justice is done. Of course, now that the killer is revealed, she suddenly undergoes a complete personality shift--her character gets completely rewritten, because the writers don't need to keep her identity secret any more. The cheese completely sinks what otherwise could have been a passably amusing movie.", - "I thought this movie did a down right good job. It wasn't as creative or original as the first, but who was expecting it to be. It was a whole lotta fun. the more i think about it the more i like it, and when it comes out on DVD I'm going to pay the money for it very proudly, every last cent. Sharon Stone is great, she always is, even if her movie is horrible(Catwoman), but this movie isn't, this is one of those movies that will be underrated for its lifetime, and it will probably become a classic in like 20 yrs. Don't wait for it to be a classic, watch it now and enjoy it. Don't expect a masterpiece, or something thats gripping and soul touching, just allow yourself to get out of your life and get yourself involved in theirs.All in all, this movie is entertaining and i recommend people who haven't seen it see it.", - "I rented this movie, but I wasn't too sure what to expect of it. I was very glad to find that it's about the best Brazilian movie I've ever seen. The story is rather odd and simple, and above all, extremely original. We have Antonio, who is a young man living in Nordestina, a town in the middle of nowhere in the north east of Brazil, and who is deeply in love with Karina. The main conflict between the two is that, while Antonio loves his little town and has no wish to leave it, Karina wants to see the world and resents the place. As a prove of his love for her, he decides to go out himself and bring the world to her. He'll put Nordestina in the map, as he says. And the way he does it is unbelievable. This is a good movie; might be a bit stagy for some people due to its different editing job, but I think that it's also that that improves the story. It's just fun, and it makes you feel good."]) -label = gradio.outputs.Label(postprocessing_fn=postprocessing) -io = gradio.Interface(inputs=textbox, outputs=label, model_type="keras", model=model, saliency=saliency, always_flag=True) -httpd, path_to_local_server, share_url = io.launch(share=True, inbrowser=True, inline=False) - -print("URL for IMDB model interface: ", share_url) diff --git a/examples/imdb_utils.py b/examples/imdb_utils.py deleted file mode 100644 index 561700c868..0000000000 --- a/examples/imdb_utils.py +++ /dev/null @@ -1,52 +0,0 @@ -import tensorflow as tf -from tensorflow.keras.layers import * -from tensorflow.keras.datasets import imdb -import json -import numpy as np - -top_words = 5000 # Only keep the 5,000 most frequent words -max_word_length = 500 # The maximum length of the review should be 500 words (trim/pad otherwise) - - -NUM_SPECIAL_TOKENS = 3 -PAD_TOKEN = 0 -START_TOKEN = 1 -UNK_TOKEN = 2 - -word_to_id = tf.keras.datasets.imdb.get_word_index() -word_to_id = {k: (v + NUM_SPECIAL_TOKENS) for k, v in word_to_id.items()} - -id_to_word = {value: key for key, value in word_to_id.items()} -id_to_word[PAD_TOKEN] = "" # Padding tokens are converted to empty strings. -id_to_word[START_TOKEN] = "" # Start tokens are converted to empty strings. -id_to_word[UNK_TOKEN] = "UNK" # tokens are converted to "UNK". - - -def decode_vector_to_text(vector): - text = " ".join(id_to_word[id] for id in vector if id >= 2) - return text - - -def encode_text_to_vector(text, max_word_length=500, top_words=5000): - text_vector = text.split(" ") - encoded_vector = [ - word_to_id.get(element, UNK_TOKEN) if word_to_id.get(element, UNK_TOKEN) < top_words else UNK_TOKEN for element - in text_vector] - encoded_vector = [START_TOKEN] + encoded_vector - if len(encoded_vector) < max_word_length: - encoded_vector = (max_word_length - len(encoded_vector)) * [PAD_TOKEN] + encoded_vector - else: - encoded_vector = encoded_vector[:max_word_length] - return encoded_vector - - -def preprocessing(text): - new = encode_text_to_vector(text) - return tf.keras.preprocessing.sequence.pad_sequences([new], maxlen=max_word_length) - - -def postprocessing(pred): - return { - "Positive review": f"{pred[0][0]}", - "Negative review": f"{1-pred[0][0]}" - } diff --git a/examples/mnist_interactive.py b/examples/mnist_interactive.py deleted file mode 100644 index f9299493e4..0000000000 --- a/examples/mnist_interactive.py +++ /dev/null @@ -1,38 +0,0 @@ -import tensorflow as tf -import sys -sys.path.insert(1, '../gradio') -import gradio -from tensorflow.keras.layers import * - - -(x_train, y_train),(x_test, y_test) = tf.keras.datasets.mnist.load_data() -x_train, x_test = x_train.reshape(-1,784) / 255.0, x_test.reshape(-1,784) / 255.0 - - -def get_trained_model(n): - model = tf.keras.models.Sequential() - model.add(Reshape((28, 28, 1), input_shape=(784,))) - model.add(Conv2D(32, kernel_size=(3, 3), activation='relu')) - model.add(Conv2D(64, (3, 3), activation='relu')) - model.add(MaxPooling2D(pool_size=(2, 2))) - model.add(Dropout(0.25)) - model.add(Flatten()) - model.add(Dense(128, activation='relu')) - model.add(Dropout(0.5)) - model.add(Dense(10, activation='softmax')) - model.compile(optimizer='adam', loss='sparse_categorical_crossentropy', metrics=['accuracy']) - model.fit(x_train[:n], y_train[:n], epochs=2) - print(model.evaluate(x_test, y_test)) - return model - - -model = get_trained_model(n=50000) - -# Gradio code # -sketchpad = gradio.inputs.Sketchpad(flatten=True, sample_inputs=x_test[:10]) -label = gradio.outputs.Label(show_confidences=False) -io = gradio.Interface(inputs=sketchpad, outputs=label, model=model, model_type="keras", verbose=False, - always_flag=True) -httpd, path_to_local_server, share_url = io.launch(inline=True, share=True, inbrowser=True) - -print("URL for MNIST model interface: ", share_url) diff --git a/examples/mnist_saliency.py b/examples/mnist_saliency.py deleted file mode 100644 index 25cb18501d..0000000000 --- a/examples/mnist_saliency.py +++ /dev/null @@ -1,51 +0,0 @@ -import tensorflow as tf -import sys -sys.path.insert(1, '../gradio') -import gradio -from tensorflow.keras.layers import * -from tensorflow.keras import backend as K - -(x_train, y_train),(x_test, y_test) = tf.keras.datasets.mnist.load_data() -x_train, x_test = x_train.reshape(-1,784) / 255.0, x_test.reshape(-1,784) / 255.0 - - -def get_trained_model(n): - model = tf.keras.models.Sequential() - model.add(Reshape((28, 28, 1), input_shape=(784,))) - model.add(Conv2D(32, kernel_size=(3, 3), activation='relu')) - model.add(Conv2D(64, (3, 3), activation='relu')) - model.add(MaxPooling2D(pool_size=(2, 2))) - model.add(Dropout(0.25)) - model.add(Flatten()) - model.add(Dense(128, activation='relu')) - model.add(Dropout(0.5)) - model.add(Dense(10, activation='softmax')) - model.compile(optimizer='adam', loss='sparse_categorical_crossentropy', metrics=['accuracy']) - model.fit(x_train[:n], y_train[:n], epochs=2) - print(model.evaluate(x_test, y_test)) - return model - - -def saliency(interface, model, input, processed_input, output, processed_output): - with interface.graph.as_default(): - with interface.sess.as_default(): - output = output.argmax() - input_tensors = [model.inputs[0], K.learning_phase()] - saliency_input = model.layers[0].input - saliency_output = model.layers[-1].output[:, output] - gradients = model.optimizer.get_gradients(saliency_output, saliency_input) - compute_gradients = K.function(inputs=input_tensors, outputs=gradients) - saliency_graph = compute_gradients(processed_input.reshape(-1, 784)) - normalized_saliency = (abs(saliency_graph[0]) - abs(saliency_graph[0]).min()) / \ - (abs(saliency_graph[0]).max() - abs(saliency_graph[0]).min()) - return normalized_saliency.reshape(28, 28) - - -model = get_trained_model(n=50000) - -sketchpad = gradio.inputs.Sketchpad(flatten=True, sample_inputs=x_test[:10]) -label = gradio.outputs.Label(show_confidences=False) -io = gradio.Interface(inputs=sketchpad, outputs=label, model=model, model_type="keras", saliency=saliency, always_flag=True) -httpd, path_to_local_server, share_url = io.launch(inline=True, share=True, inbrowser=True) - -print("URL for MNIST model interface with saliency:", share_url) diff --git a/examples/mnist_saliency_only.py b/examples/mnist_saliency_only.py deleted file mode 100644 index 1f65e524b7..0000000000 --- a/examples/mnist_saliency_only.py +++ /dev/null @@ -1,50 +0,0 @@ -import tensorflow as tf -import sys -sys.path.insert(1, '../gradio') -import gradio -from tensorflow.keras.layers import * -from tensorflow.keras import backend as K - -(x_train, y_train),(x_test, y_test) = tf.keras.datasets.mnist.load_data() -x_train, x_test = x_train.reshape(-1,784) / 255.0, x_test.reshape(-1,784) / 255.0 - - -def get_trained_model(n): - model = tf.keras.models.Sequential() - model.add(Reshape((28, 28, 1), input_shape=(784,))) - model.add(Conv2D(32, kernel_size=(3, 3), activation='relu')) - model.add(Conv2D(64, (3, 3), activation='relu')) - model.add(MaxPooling2D(pool_size=(2, 2))) - model.add(Dropout(0.25)) - model.add(Flatten()) - model.add(Dense(128, activation='relu')) - model.add(Dropout(0.5)) - model.add(Dense(10, activation='softmax')) - model.compile(optimizer='adam', loss='sparse_categorical_crossentropy', metrics=['accuracy']) - model.fit(x_train[:n], y_train[:n], epochs=2) - print(model.evaluate(x_test, y_test)) - return model - - -def saliency(interface, model, input, processed_input, output, processed_output): - with interface.graph.as_default(): - with interface.sess.as_default(): - output = output.argmax() - input_tensors = [model.inputs[0], K.learning_phase()] - saliency_input = model.layers[0].input - saliency_output = model.layers[-1].output[:, output] - gradients = model.optimizer.get_gradients(saliency_output, saliency_input) - compute_gradients = K.function(inputs=input_tensors, outputs=gradients) - saliency_graph = compute_gradients(processed_input.reshape(-1, 784)) - normalized_saliency = (abs(saliency_graph[0]) - abs(saliency_graph[0]).min()) / \ - (abs(saliency_graph[0]).max() - abs(saliency_graph[0]).min()) - return normalized_saliency.reshape(28, 28) - - -model = get_trained_model(n=50000) - -sketchpad = gradio.inputs.Sketchpad(flatten=True, sample_inputs=x_test[:10]) -io = gradio.Interface(inputs=sketchpad, outputs="label", model=model, model_type="keras", saliency=saliency, always_flag=True, interactivity_disabled=True) -httpd, path_to_local_server, share_url = io.launch(inline=True, share=True, inbrowser=True) - -print("URL for MNIST model interface with saliency:", share_url) diff --git a/gradio/interface.py b/gradio/interface.py index 22a10db5ba..7fee814d6a 100644 --- a/gradio/interface.py +++ b/gradio/interface.py @@ -307,13 +307,14 @@ class Interface: config["share_url"] = share_url processed_examples = [] - for example_set in self.examples: - processed_set = [] - for iface, example in zip(self.input_interfaces, example_set): - processed_set.append(iface.process_example(example)) - processed_examples.append(processed_set) + if self.examples is not None: + for example_set in self.examples: + processed_set = [] + for iface, example in zip(self.input_interfaces, example_set): + processed_set.append(iface.process_example(example)) + processed_examples.append(processed_set) + config["examples"] = processed_examples - config["examples"] = processed_examples networking.set_config(config, output_directory) return httpd, path_to_local_server, share_url