阿里云ECS训练营入门Class4——基于ECS和NAS搭建个人网盘

本节课整个场景体验
在这里插入图片描述
阿里云社区有许多场景供我们体验,所需的云产品资源都会免费提供,但开启试用之后要及时完成体验过程,资源会在一定时间后释放。

创建资源

体验界面右侧云产品资源栏下点击 免费开通 按钮,开始创建实验资源。

说明:资源创建过程需要1-3分钟。完成实验资源的创建后,用户可以通过 云产品资源 查看实验中所需的资源信息,例如:IP地址、用户名、密码等。
在这里插入图片描述
在这里插入图片描述

连接ECS服务器

1、 打开终端工具。

Windows:打开命令窗口,win+r,输入cmd 回车
MAC:打开命令行终端Terminal
2、在终端中输入连接命令ssh [username]@[ipaddress]。其中 username 为创建的ECS服务器的用户名;ipaddress替换为弹性IP,例如:

ssh root@47.101.170.65

3、输入yes后再输入服务器密码(输入时密码不可见)

登录成功后如下图所示(一开始命令输错了【捂脸】)
在这里插入图片描述

安装 OwnCloud

OwnCloud是一款开源的云存储软件,基于PHP的自建网盘,支持多个平台(windows,MAC,Android,IOS,Linux)。
执行以下命令:
1、添加新的软件源

rpm --import https://download.owncloud.org/download/repositories/10.0/CentOS_7/repodata/repomd.xml.key

wget http://download.owncloud.org/download/repositories/10.0/CentOS_7/ce:10.0.repo -O /etc/yum.repos.d/ce:10.0.repo

在这里插入图片描述
在这里一开始输入指令都没有什么反应,老是出错
在这里插入图片描述
便去小组群里询问学长学姐,才得知是没有连接上ssh,看来我是盲目地input指令不看运行结果(sillyme*1)

2、执行以下命令安装OwnCloud-files

yum install owncloud-files

在这里插入图片描述

3、 执行以下命令查看安装是否成功

ll /var/www/html

在这里插入图片描述

安装 Apache 服务

1、执行以下命令安装 Apache 服务

yum install httpd –y

在这里插入图片描述
2、执行以下命令启动Apache服务

systemctl start httpd.service

3、打开浏览器输入体验平台创建的ECS的弹性公网IP。如果出现如下图内容表示Apache安装成功!
在这里插入图片描述
4、添加OwnCloud配置:
i)打开Apache配置文件

vim /etc/httpd/conf/httpd.conf

在这里插入图片描述
ii)按i键进入文件编辑模式,然后在内容后添加以下内容

# owncloud config
Alias /owncloud "/var/www/html/owncloud/"
<Directory /var/www/html/owncloud/>
    Options +FollowSymlinks
    AllowOverride All
    <IfModule mod_dav.c>
        Dav off
    </IfModule>
    SetEnv HOME /var/www/html/owncloud
    SetEnv HTTP_HOME /var/www/html/owncloud
</Directory>

在这里插入图片描述
打开配置文件后是一脸懵,满屏蓝字,还要按 i 键,都不知道在哪输入,于是又请教小组大佬们,他们说直接输入就行,我按了…依然没有反应,结果又被告知要英文输入(sillyme * 2)我竟然这么基本的意识都没有,正确操作之后,最下面一行出现了—INSERT—,but我依然没有看到所谓的,结果我又来求助惹…哇! 还可以方向键翻页(sillyme*3)里面内容还不少【害怕】找了一会儿,终于给我找到了,
在这里插入图片描述
但是问题又来了,无法输入要插入的内容,怎么回事,卡了🐎?额(sillyme*4)再次询问了小组大佬们,原来是光标没选对【笑哭】是那个小的由方向键控制的光标而不是鼠标点击的…彳亍 口 巴 !终究还是完成这小小的操作惹。

iii)按esc键退出编辑模式,然后输入:wq保存并退出配置文件
在这里插入图片描述

安装并配置PHP

1、 执行以下命令手动更新rpm源

rpm -Uvh https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm   
rpm -Uvh https://mirror.webtatic.com/yum/el7/webtatic-release.rpm   

2、执行以下命令安装PHP 7.2版本
说明:OwnCloud只支持PHP 5.6+

yum -y install php72w
yum -y install php72w-cli php72w-common php72w-devel php72w-mysql php72w-xml php72w-odbc php72w-gd php72w-intl php72w-mbstring

3、执行以下命令可以检测PHP是否安装成功

php -v

4、将PHP配置到Apache中,执行如下命令:
i)找到php.ini文件目录

find / -name php.ini

ii)打开httpd.conf文件

vi /etc/httpd/conf/httpd.conf

iii)按i键进入文件编辑模式,然后在文件最后添加以下内容

PHPIniDir /etc/php.ini

有了之前的教训,再也不会silly了!

iv)按esc键退出编辑模式,然后输入:wq保存并退出配置文件
v)重启Apache服务

systemctl restart httpd.service

配置OwnCloud

上述内容配置成功后,就可以登录OwnCloud创建个人网盘了,因为个人能力太不给力,体验免费开通的资源已经释放,所以不能实操惹【/(ㄒoㄒ)/~~】

1、打开浏览器,输入ECS弹性IP/owncloud,例如39.98.122.246/owncloud

2、创建管理员账号和密码,然后单击【存储&数据库】,配置数据库,最后单击【安装完成】
在这里插入图片描述
3、输入已创建的用户名和密码登录Owncloud
在这里插入图片描述
登录成功即可。

挂载NAS服务

具体操作还是看实验详情吧【跪】

如上就是本次场景的全部体验内容,可以多次体验噢

这是我第一次进行如此“复杂”的操作,感觉有点码农搬砖的味儿了,虽然是按照实验步骤一步步来的,可是还是遇到了许多麻烦,我在体验前还觉得这难不倒我,没想到还是【跪】了。这真是“文档得来终觉浅,绝知此事要躬行”
还得多动手,不然是不知道直接是多么silly。

  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
首先,我们需要装PyTorch和其他必要的库。可以使用以下命令装PyTorch: ``` pip install torch torchvision ``` 其他库可以使用以下命令装: ``` pip install numpy pandas matplotlib opencv-python ``` 接下来,我们需要下载DPN92预训练模型的权重。可以使用以下命令下载: ``` wget https://github.com/c0nn3r/DPN/releases/download/v2.0/DPN92_extra_5k.pth.tar ``` 现在开始设计模型。我们将使用PyTorch中的预训练模型和自定义头来实现图像检测和分类。以下是完整的代码: ```python import torch import torch.nn as nn import torch.nn.functional as F import torchvision.transforms as transforms import cv2 import numpy as np # Define the custom head for object detection class DetectionHead(nn.Module): def __init__(self, in_channels, num_classes): super(DetectionHead, self).__init__() self.conv1 = nn.Conv2d(in_channels, in_channels, kernel_size=3, stride=1, padding=1) self.bn1 = nn.BatchNorm2d(in_channels) self.conv2 = nn.Conv2d(in_channels, in_channels, kernel_size=3, stride=1, padding=1) self.bn2 = nn.BatchNorm2d(in_channels) self.conv3 = nn.Conv2d(in_channels, in_channels, kernel_size=3, stride=1, padding=1) self.bn3 = nn.BatchNorm2d(in_channels) self.conv4 = nn.Conv2d(in_channels, num_classes * 5, kernel_size=3, stride=1, padding=1) def forward(self, x): x = F.relu(self.bn1(self.conv1(x))) x = F.relu(self.bn2(self.conv2(x))) x = F.relu(self.bn3(self.conv3(x))) x = self.conv4(x) return x # Define the model class DPN92Detection(nn.Module): def __init__(self, num_classes): super(DPN92Detection, self).__init__() self.dpn92 = torch.hub.load('rwightman/pytorch-dpn-pretrained', 'dpn92', pretrained=True) self.head = DetectionHead(2688, num_classes) def forward(self, x): x = self.dpn92.features(x) x = F.avg_pool2d(x, kernel_size=7, stride=1) x = x.view(x.size(0), -1) x = self.head(x) return x # Define the class names class_names = ['class0', 'class1', 'class2', 'class3', 'class4'] # Load the model and the weights model = DPN92Detection(num_classes=len(class_names)) model.load_state_dict(torch.load('DPN92_extra_5k.pth.tar', map_location='cpu')['state_dict']) # Set the model to evaluation mode model.eval() # Define the image transformer image_transforms = transforms.Compose([ transforms.ToPILImage(), transforms.Resize((224, 224)), transforms.ToTensor(), transforms.Normalize([0.485, 0.456, 0.406], [0.229, 0.224, 0.225]), ]) # Load the image image = cv2.imread('test.jpg') # Transform the image input_image = image_transforms(image) input_image = input_image.unsqueeze(0) # Make a prediction with torch.no_grad(): output = model(input_image) # Get the class probabilities class_probs = F.softmax(output[:, :len(class_names)], dim=1) # Get the bounding box coordinates, sizes and class indices coords_sizes_classes = output[:, len(class_names):].view(-1, 5) coords_sizes_classes[:, :2] = torch.sigmoid(coords_sizes_classes[:, :2]) coords_sizes_classes[:, 2] = torch.exp(coords_sizes_classes[:, 2]) coords_sizes_classes[:, 3:5] = torch.argmax(coords_sizes_classes[:, 3:], dim=1).unsqueeze(1) coords_sizes_classes = coords_sizes_classes.cpu().numpy() # Filter out the boxes with low confidence conf_threshold = 0.5 filtered_boxes = coords_sizes_classes[class_probs[0] > conf_threshold] # Draw the boxes on the image for box in filtered_boxes: x, y, w, h, c = box x *= image.shape[1] y *= image.shape[0] w *= image.shape[1] h *= image.shape[0] x1 = int(x - w / 2) y1 = int(y - h / 2) x2 = int(x + w / 2) y2 = int(y + h / 2) cv2.rectangle(image, (x1, y1), (x2, y2), (0, 255, 0), 2) cv2.putText(image, class_names[int(c)], (x1, y1 - 10), cv2.FONT_HERSHEY_SIMPLEX, 0.9, (0, 255, 0), 2) # Show the image cv2.imshow('Image', image) cv2.waitKey(0) cv2.destroyAllWindows() ``` 在上面的代码中,我们定义了一个名为`DetectionHead`的自定义头,用于检测图像中的对象,并输出它们的坐标、大小和类别。然后,我们定义了一个名为`DPN92Detection`的模型,该模型使用DPN92预训练模型和自定义头进行图像检测和分类。我们还定义了一些变量,如类名、图像变换器、置信度阈值等。最后,我们将模型和权重加载到内存中,并使用`cv2`库加载图像。我们将图像传递给模型,然后使用`softmax`函数获取类别概率,使用`sigmoid`和`exp`函数获取边界框的坐标和大小,并使用`argmax`函数获取类别索引。最后,我们过滤掉低置信度的边界框,并将它们绘制在原始图像上。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值