1
00:00:00,540 --> 00:00:01,780
Hi and welcome back.

2
00:00:01,860 --> 00:00:08,220
So in this section, we'll take a look at another medical data application where we'll be taking a look

3
00:00:08,220 --> 00:00:13,260
at X-rays, chest X-rays to detect if pneumonia is present.

4
00:00:13,500 --> 00:00:15,600
And we're going to use to be used to do this.

5
00:00:15,610 --> 00:00:18,540
So all the time we're using GPUs, sometimes CPU's.

6
00:00:19,050 --> 00:00:23,170
Now we're going to use something called Google's TP Use, which our Tensor Processing Units.

7
00:00:23,180 --> 00:00:26,760
So open Notebook 70 and we'll get started.

8
00:00:26,880 --> 00:00:34,340
So firstly, again, this came from the Keros official tutorial site, and it's prepared by Amy McEwen

9
00:00:34,740 --> 00:00:35,080
Young.

10
00:00:35,460 --> 00:00:37,980
So let's get started with this lesson.

11
00:00:38,640 --> 00:00:45,120
So firstly, let's basically just load the libraries here, and we're going to actually start using

12
00:00:45,120 --> 00:00:46,410
the TPU is here.

13
00:00:46,950 --> 00:00:51,960
So by using these functions here, we're going to get the number of TPA calls that we have and you can

14
00:00:51,960 --> 00:00:53,740
see we have eight cores available.

15
00:00:53,760 --> 00:00:55,980
Number four, because means number of calls here.

16
00:00:56,760 --> 00:01:00,720
Well, to have one tip, you could turn on both with his picture.

17
00:01:01,200 --> 00:01:02,280
Sorry to be used to look.

18
00:01:02,490 --> 00:01:09,450
So basically one tip you would it, which is effectively said no, we just set some parameters here,

19
00:01:09,450 --> 00:01:10,770
as well as a class lens.

20
00:01:11,360 --> 00:01:13,040
And now we load the data.

21
00:01:13,050 --> 00:01:19,500
So this data we are using from so and we can take a look at that source here is basically some medical

22
00:01:19,890 --> 00:01:25,380
data repository that talks about how to use deep learning for medical practices.

23
00:01:25,800 --> 00:01:31,410
It's a very good read, actually, if you're interested in the health sector of computer vision, so

24
00:01:31,410 --> 00:01:33,720
I would encourage you to encourage you to check it out.

25
00:01:34,590 --> 00:01:40,230
So now let's take a look at so let's count how much normal, healthy chest X-rays there are and how

26
00:01:40,230 --> 00:01:40,950
much pneumonia.

27
00:01:41,500 --> 00:01:49,320
And you can see there a lot more pneumonia X-rays in this count by maybe an order of almost at least

28
00:01:49,320 --> 00:01:51,020
twice, almost three times.

29
00:01:51,020 --> 00:01:56,220
Sorry, I should say, of the normal images, normal lung scans here.

30
00:01:57,060 --> 00:02:00,570
So we do have to correct for those class imbalances a bit afterward.

31
00:02:00,690 --> 00:02:05,160
But for now, let's create some hope of functions that we'll be using later on.

32
00:02:05,850 --> 00:02:12,570
And now we can split the data into test and validation data sets here, and we just load the format

33
00:02:12,750 --> 00:02:13,650
from other data.

34
00:02:13,830 --> 00:02:14,310
That's right.

35
00:02:14,640 --> 00:02:16,470
The format of the test data as well.

36
00:02:17,310 --> 00:02:19,380
And now we can visualize the data.

37
00:02:19,380 --> 00:02:24,030
So let's take a look at this function that visualizes, takes a batch and returns it so we can visualize

38
00:02:24,030 --> 00:02:27,330
it during this period of training history.

39
00:02:27,330 --> 00:02:32,960
And this is the function of returns that batch of data using the item itself.

40
00:02:33,220 --> 00:02:35,790
You would see you get a batch of data there.

41
00:02:36,240 --> 00:02:42,450
And now this is a function that shows the batch of data here so we can take a look and you can see what

42
00:02:42,450 --> 00:02:47,250
pneumonia X-ray scans look like and what normal chest x ray scans look like.

43
00:02:47,820 --> 00:02:56,490
And as you can see, there's not much normal is just one two three four for normal lung scans and a

44
00:02:56,490 --> 00:02:58,170
lot more pneumonia scans.

45
00:02:59,160 --> 00:03:07,740
And you can see it's very hard for me as a layperson who is not an X-ray technician to understand what's

46
00:03:07,740 --> 00:03:10,380
the difference between a pneumonia lung and a normal lung.

47
00:03:10,890 --> 00:03:15,630
You can kind of see, at least to me, the normal lungs tend to look smaller.

48
00:03:15,750 --> 00:03:17,910
Except for this one, I'm not sure.

49
00:03:18,660 --> 00:03:19,880
I'm honestly not sure.

50
00:03:19,890 --> 00:03:24,870
Maybe, maybe it's to do with the clarity of how the deeper the blacks look.

51
00:03:25,500 --> 00:03:27,860
Perhaps, but then again, that's not all.

52
00:03:27,870 --> 00:03:30,720
That's true, so I'm honestly not sure what they're looking for.

53
00:03:30,720 --> 00:03:32,160
Maybe deep learning can pick it up.

54
00:03:33,150 --> 00:03:34,880
So now let's build on CNN.

55
00:03:34,890 --> 00:03:41,130
So this creates a building block, functions here to block dense block, and we just create a model.

56
00:03:41,130 --> 00:03:47,430
And you can see this model is just a simple model of convolutional is some dense blocks at the end,

57
00:03:47,430 --> 00:03:50,160
pretty much a standard video type network.

58
00:03:51,330 --> 00:03:54,210
And here we correct for the class imbalance as well.

59
00:03:54,750 --> 00:03:59,790
So you can give we give each class a width and then we start treating the model.

60
00:03:59,940 --> 00:04:03,300
So let's take a look at the training section here.

61
00:04:03,780 --> 00:04:09,900
So just to final check points at our initial learning rate to get a listing of its schedule and then

62
00:04:09,910 --> 00:04:15,570
now we can start compiling the final metrics and start treating to model finally.

63
00:04:16,170 --> 00:04:20,070
So you can see trends per relatively quickly and then stop 779 epochs.

64
00:04:20,920 --> 00:04:26,100
So that's because it probably reached the early stopping threshold and you can see your validation.

65
00:04:26,100 --> 00:04:33,630
Lewis was pretty much all over the place at that point, but the accuracy was ninety seven percent and

66
00:04:34,560 --> 00:04:39,690
the precision I'm sorry and record is actually quite good, as well as a very good scores, I must say.

67
00:04:40,560 --> 00:04:43,010
So now let's visualize the model performance as well.

68
00:04:43,020 --> 00:04:48,120
You can see the scores going up as e-books go, as well as the loss going down.

69
00:04:49,770 --> 00:04:52,350
So actually, we are surpassing 95 percent, I believe.

70
00:04:53,430 --> 00:04:58,980
Then we get that 97 percent, actually, although sometimes we're at ninety eight as well.

71
00:04:59,100 --> 00:04:59,490
So that's.

72
00:04:59,760 --> 00:05:00,000
Good.

73
00:05:01,140 --> 00:05:03,720
So, no, this is a prediction here.

74
00:05:04,200 --> 00:05:11,220
This image is 28 percent probability of it being normal and 71 for it being pneumonia.

75
00:05:12,270 --> 00:05:15,410
And apparently this was a normal lung.

76
00:05:16,500 --> 00:05:21,870
If I'm not mistaken, maybe you can try another sample because this probably should not have.

77
00:05:23,160 --> 00:05:23,880
OK, there we go.

78
00:05:23,880 --> 00:05:28,290
So that actually wasn't the correct by coincidence of incorrect classification.

79
00:05:28,740 --> 00:05:34,230
So this one, the network says it's 99 percent normal and it actually is normal.

80
00:05:34,800 --> 00:05:35,970
So that's pretty good.

81
00:05:37,770 --> 00:05:39,270
So that's it for this lesson.

82
00:05:39,390 --> 00:05:43,320
It's actually a very good lesson if you wanted to start learning about medical data.

83
00:05:43,950 --> 00:05:46,860
So I would encourage you to read that link above.

84
00:05:47,610 --> 00:05:49,350
And that's it for this lesson.

85
00:05:49,500 --> 00:05:50,370
Hope you enjoyed it.

86
00:05:50,460 --> 00:05:51,270
Thank you for watching.
