当城市有一个词时,我的JS很好:
但是当它的时候
我怎样才能成为圣地亚哥?
function convert_case() {
document.profile_form.city.value =
document.profile_form.city.value.substr(0,1).toUpperCase() +
document.profile_form.city.value.substr(1).toLowerCase();
}
Run Code Online (Sandbox Code Playgroud) 我认为如果有针对CIFAR-10教程中由convnet创建的模型测试单个新图像的关键任务的详细解决方案,那么Tensorflow社区将会非常有用.
我可能错了,但是这个让训练有素的模型在实践中可用的关键步骤似乎缺乏.该教程中有一个"缺失的链接" - 一个直接加载单个图像(作为数组或二进制文件)的脚本,将其与训练模型进行比较,然后返回分类.
先前的答案提供了解释整体方法的部分解决方案,但我没有能够成功实施.其他零碎可以在这里和那里找到,但遗憾的是还没有添加到一个可行的解决方案.在将此标记为重复或已经回答之前,请考虑我已完成的研究.
https://gist.github.com/nikitakit/6ef3b72be67b86cb7868
最流行的答案是第一个,其中@RyanSepassi和@YaroslavBulatov描述了问题和方法:人们需要"手动构建具有相同节点名称的图形,并使用Saver将权重加载到其中".虽然这两个答案都很有帮助,但是如何将其插入CIFAR-10项目并不明显.
一个功能齐全的解决方案非常需要,因此我们可以将其移植到其他单个图像分类问题中.在这方面SO有几个问题要求这个,但仍然没有完整的答案(例如加载检查点并评估具有张量流DNN的单个图像).
我希望我们能够集中在每个人都可以使用的工作脚本上.
以下脚本尚未正常运行,我很高兴听到您如何改进,以便使用CIFAR-10 TF教程训练模型为单图像分类提供解决方案.
假设所有变量,文件名等都不受原始教程的影响.
新文件:cifar10_eval_single.py
import cv2
import tensorflow as tf
FLAGS = tf.app.flags.FLAGS
tf.app.flags.DEFINE_string('eval_dir', './input/eval',
"""Directory where to write event logs.""")
tf.app.flags.DEFINE_string('checkpoint_dir', './input/train',
"""Directory where to read model checkpoints.""")
def get_single_img():
file_path = './input/data/single/test_image.tif'
pixels = cv2.imread(file_path, 0)
return pixels
def eval_single_img():
# below code adapted from @RyanSepassi, however not functional
# among other errors, saver throws an error that …Run Code Online (Sandbox Code Playgroud) 我正在尝试调整一组256 x N像素的灰度图像(N变化,但始终≤256).
我的目的是缩小图像尺寸.
调整大小必须输出方形(1:1)图像,其中:
在视觉上这将是期望的结果:
我尝试使用目标大小(例如200 x 200)创建一个numpy零点矩阵,但无法将调整大小的图像粘贴到其垂直中心.
任何使用cv2,PIL或numpy的建议都是受欢迎的.
我的页面在页面顶部有这个额外的填充,我无法删除.在阳光下尝试了一切,希望有人能指路我.
有任何想法吗?
我想在一些将输出到视图的文本上使用Ext的String方法.
例如:
itemTpl: [
...
'<tpl switch="post_type">',
'<tpl case="new_user">',
'<p>{post_text_teaser}</p>',
'<p>{timestamp}</p>',
'<tpl default>',
'<p>' + Ext.String.ellipsis( + '{post_text_teaser}' + \, 4) + '</p>',
...
].join(''),
Run Code Online (Sandbox Code Playgroud)
但当然第10行的连接是非法的.
你知道它是否可能或如何正确地做到这一点?
给出以下字符串
http://thedude.com/05/simons-cat-and-frog-100x100.jpg
Run Code Online (Sandbox Code Playgroud)
我想使用substr或trim(或任何你认为更合适的东西)来返回它
http://thedude.com/05/simons-cat-and-frog.jpg
Run Code Online (Sandbox Code Playgroud)
也就是说,删除-100x100.我需要的所有图像都会在扩展名之前标记到文件名的末尾.
似乎有关于SO和Ruby和Python的响应,但不是PHP /特定于我的需求.
有什么建议?
我正在成功地将博客文章中的缩略图加载到我的UITableView中.
我遇到的问题是,如果我点击单元格或者向下滚动,图像才会出现.
当我点击单元格时,图像显示在左侧,将标题和副标题推向右侧.
向下滚动时,图像会显示在细胞显示的位置.
这是我的代码(我正在使用AFNetworking):
#import "UIImageView+AFNetworking.h"
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
return posts.count;
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
static NSString *CellIdentifier = @"cell";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil) {
cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:CellIdentifier];
}
NSDictionary *post = [posts objectAtIndex:indexPath.row];
NSString *postpictureUrl = [post objectForKey:@"picture"];
[cell.imageView setImageWithURL:[NSURL URLWithString:postpictureUrl]];
cell.textLabel.text = [post objectForKey:@"post_text"];
cell.detailTextLabel.text = [post objectForKey:@"post_author_name"];
return cell;
}
Run Code Online (Sandbox Code Playgroud)
我在iPhone 6.0模拟器,XCode 4.5,OSX MtLion中看到了这一点.
任何想法为什么图像不在初始屏幕上绘制?
我能够训练带有二进制分类标记图像的U-net.
但我很难弄清楚如何在Keras/Theano中配置最终层以进行多类分类(4类).
我有634个图像和相应的634个掩码,unit864 x 64像素.
我的面具不是黑色(0)和白色(1),而是在3个类别加上背景的颜色标记对象,如下所示:
在训练运行之前,包含掩码的数组是单热编码,如下所示:
mask_train = to_categorical(mask_train, 4)
Run Code Online (Sandbox Code Playgroud)
这使得mask_train.shape从去(634, 1, 64, 64)到(2596864, 4).
我的模型紧跟Unet架构,但最终层似乎有问题,因为我无法展平结构以匹配单热编码阵列.
[...]
up3 = concatenate([UpSampling2D(size=(2, 2))(conv7), conv2], axis=1)
conv8 = Conv2D(128, (3, 3), activation='relu', padding='same')(up3)
conv8 = Conv2D(128, (3, 3), activation='relu', padding='same')(conv8)
up4 = concatenate([UpSampling2D(size=(2, 2))(conv8), conv1], axis=1)
conv9 = Conv2D(64, (3, 3), activation='relu', padding='same')(up4)
conv10 = Conv2D(64, (3, 3), activation='relu', padding='same')(conv9)
# here I used number classes …Run Code Online (Sandbox Code Playgroud) python machine-learning image-segmentation deep-learning keras
我正在使用UICollectionView在主视图中生成多个缩略图.
这工作正常,我能够在单元格周围放置边框以及应用边框(角落)半径.
唯一似乎没有坚持的是每个细胞的阴影.
这是我的代码
....
[cell.layer setBorderColor:[UIColor colorWithRed:213.0/255.0f green:210.0/255.0f blue:199.0/255.0f alpha:1.0f].CGColor];
[cell.layer setBorderWidth:1.0f];
[cell.layer setCornerRadius:7.5f];
[cell.layer setShadowOffset:CGSizeMake(0, 1)];
[cell.layer setShadowColor:[[UIColor darkGrayColor] CGColor]];
[cell.layer setShadowRadius:8.0];
[cell.layer setShadowOpacity:0.8];
return cell;
Run Code Online (Sandbox Code Playgroud)
你知道我做错了什么,我能做些什么让阴影展现出来?
我在Keras成功训练了一个简单的模型来分类图像:
model = Sequential()
model.add(Convolution2D(32, 3, 3, border_mode='valid', input_shape=(img_channels, img_rows, img_cols),
activation='relu', name='conv1_1'))
model.add(Convolution2D(32, 3, 3, activation='relu', name='conv1_2'))
model.add(MaxPooling2D(pool_size=(2, 2)))
model.add(Dropout(0.25))
model.add(Convolution2D(64, 3, 3, border_mode='valid', activation='relu', name='conv2_1'))
model.add(Convolution2D(64, 3, 3, activation='relu', name='conv2_2'))
model.add(MaxPooling2D(pool_size=(2, 2)))
model.add(Dropout(0.25))
model.add(Flatten())
model.add(Dense(512, activation='relu'))
model.add(Dropout(0.5))
model.add(Dense(nb_classes, activation='softmax'))
model.compile(loss='categorical_crossentropy', optimizer=sgd, metrics=['accuracy'])
Run Code Online (Sandbox Code Playgroud)
我也可以使用预测图像类
y_pred = model.predict_classes(img, 1, verbose=0)
Run Code Online (Sandbox Code Playgroud)
但是输出y_pred总是二进制的.使用predict_proba和时似乎也是如此predict.我的输出是这种形式
[[ 1. 0. 0. 0.]]
[[ 0. 1. 0. 0.]]
Run Code Online (Sandbox Code Playgroud)
这样可行,但我希望每个分类都有一个概率百分比
[[ 0.8 0.1 0.1 0.4]]
Run Code Online (Sandbox Code Playgroud)
我如何在Keras得到这个?
python neural-network deep-learning conv-neural-network keras
python ×4
ios ×2
javascript ×2
keras ×2
asynchronous ×1
css ×1
extjs ×1
extjs4 ×1
ios4 ×1
ios5 ×1
numpy ×1
objective-c ×1
opencv ×1
padding ×1
php ×1
python-3.x ×1
safari ×1
sencha-touch ×1
string ×1
tensorflow ×1
uitableview ×1