InvalidURL: URL can't contain control characters

92 views
Skip to first unread message

John Pap

unread,
Nov 28, 2019, 4:30:11 PM11/28/19
to TensorFlow Developers
I am following this tutorial: https://medium.com/@yannicksergeobam/plant-disease-classification-with-tensorflow-2-0-268fe7f72c2a When I run this part of code on colab:

feature_extractor = hub.KerasLayer(MODULE_HANDLE,
                                   input_shape
=IMAGE_SIZE+(3,),
                                   output_shape
=[FV_SIZE])
do_fine_tuning
= False #@param {type:"boolean"}
 
if do_fine_tuning:
    feature_extractor
.trainable = True
   
# unfreeze some layers of base network for fine-tuning
   
for layer in feature_extractor.layers[-30:]:
       layer
.trainable =True


 
else:
    feature_extractor
.trainable = False


model
= tf.keras.Sequential([
    feature_extractor
,
    tf
.keras.layers.Flatten(),
    tf
.keras.layers.Dense(512, activation='relu'),
    tf
.keras.layers.Dropout(rate=0.2),
    tf
.keras.layers.Dense(train_generator.num_classes, activation='softmax',
                           kernel_regularizer
=tf.keras.regularizers.l2(0.0001))
])

I get this error:

---------------------------------------------------------------------------


InvalidURL                                Traceback (most recent call last)


<ipython-input-16-7f860a0e8414> in <module>()
     
1 feature_extractor = hub.KerasLayer(MODULE_HANDLE,
     
2                                    input_shape=IMAGE_SIZE+(3,),
----> 3                                    output_shape=[FV_SIZE])
     
4 do_fine_tuning = True #@param {type:"boolean"}
     
5 if do_fine_tuning:


14 frames


/usr/lib/python3.6/http/client.py in putrequest(self, method, url, skip_host, skip_accept_encoding)
   
1125         match = _contains_disallowed_url_pchar_re.search(url)
   
1126         if match:
-> 1127             raise InvalidURL(f"URL can't contain control characters. {url!r} "
   
1128                              f"(found at least {match.group()!r})")
   
1129         request = '%s %s %s' % (method, url, self._http_vsn_str)


InvalidURL: URL can't contain control characters. '/google/tf2- preview/inception_v3/feature_vector/2?tf-hub-format=compressed' (found at least ' ')

Unfortunately I don't find something on google that could help me..and from the little python I know, I can't find the error...Can you help?
Reply all
Reply to author
Forward
0 new messages