【python】matplotlib(animation)

在这里插入图片描述

文章目录

  • 1、matplotlib.animation
    • 1.1、FuncAnimation
    • 1.2、修改 matplotlib 背景
  • 2、matplotlib + imageio
    • 2.1、折线图
    • 2.2、条形图
    • 2.3、散点图
  • 3、参考

1、matplotlib.animation

1.1、FuncAnimation

matplotlib.animation.FuncAnimation 是 Matplotlib 库中用于创建动画的一个类。它允许你通过循环调用一个函数来更新图表,从而生成动画效果。这个函数通常被称为“更新函数”,它决定了每一帧图表的样子。FuncAnimation 类提供了一种灵活而强大的方式来创建和展示动画,使得数据可视化更加生动和直观。

(1)基本用法

使用 FuncAnimation 创建动画的基本步骤如下:

  • 准备数据:首先,你需要准备好用于动画的数据。这可能包括一系列的X和Y坐标点、颜色、大小等,具体取决于你要制作的动画类型。
  • 创建图形和轴:使用 Matplotlib 创建图形(Figure)和轴(Axes)对象,这些对象将作为动画的画布。
  • 定义更新函数:编写一个函数,这个函数接受当前的帧号(或其他参数)作为输入,并返回一个更新后的图形元素状态。例如,如果你正在制作一个点的移动动画,这个函数可能会更新点的位置。
  • 创建 FuncAnimation 对象:使用 FuncAnimation 类创建一个动画对象。你需要指定图形对象、轴对象、更新函数、帧数(或时间间隔)、以及其他可选参数(如重复次数、初始延迟等)。
  • 显示或保存动画:最后,你可以使用 Matplotlib 的显示功能(如 plt.show())来查看动画,或者将其保存为文件(如GIF、MP4等)。

(2)示例代码

import numpy as np
import matplotlib.pyplot as plt
from matplotlib.animation import FuncAnimation# 准备数据
x = np.linspace(0, 2 * np.pi, 100)
y = np.sin(x)# 创建图形和轴
fig, ax = plt.subplots()
line, = ax.plot([], [], 'r-')  # 初始化一个空线条对象
ax.set_xlim(0, 2 * np.pi)      # 设置X轴范围
ax.set_ylim(-1.5, 1.5)         # 设置Y轴范围# 定义更新函数
def update(frame):line.set_data(x[:frame], y[:frame])  # 更新线条数据return line,# 创建 FuncAnimation 对象
ani = FuncAnimation(fig, update, frames=len(x), interval=50, blit=True)# 显示动画
plt.show()

在这里插入图片描述

在这个例子中,update 函数根据当前的帧号(frame)更新线条的数据,使得线条逐渐变长,模拟了一个点沿正弦曲线移动的动画效果。

再看一个例子

#coding=utf-8
import sysimport numpy as np
import matplotlib.pyplot as plt
import matplotlib.animation as animationfig, ax = plt.subplots()x = np.arange(0, 2*np.pi, 0.01)
line, = ax.plot(x, np.sin(x))def animate(i):line.set_ydata(np.sin(x + i/10.0))return line,def init():line.set_ydata(np.ma.array(x, mask=True))return line,ani = animation.FuncAnimation(fig, animate, np.arange(1, 200), init_func=init,interval=25, blit=True)
ani.save("animation.gif", writer="imagemagick", fps=30)
plt.show()

在这里插入图片描述

(3)matplotlib.animation.FuncAnimation

class matplotlib.animation.FuncAnimation(fig, func, frames=None, init_func=None, fargs=None, save_count=None, *, cache_frame_data=True, **kwargs)
def __init__(self,fig: Figure,func: (...) -> Iterable[Artist],frames: Iterable | int | () -> Generator | None = ...,init_func: () -> Iterable[Artist] | None = ...,fargs: tuple[Any, ...] | None = ...,save_count: int | None = ...,*,cache_frame_data: bool = ...,**kwargs: Any) -> None
`TimedAnimation` subclass that makes an animation by repeatedly calling a function *func*.  .. note::  You must store the created Animation in a variable that lives as long as the animation should run. Otherwise, the Animation object will be garbage-collected and the animation stops.  Parameters ---------- fig : `~matplotlib.figure.Figure` The figure object used to get needed events, such as draw or resize.  func : callable The function to call at each frame. The first argument will be the next value in *frames*. Any additional positional arguments can be supplied using `functools.partial` or via the *fargs* parameter.  The required signature is::  def func(frame, *fargs) -> iterable_of_artists  It is often more convenient to provide the arguments using `functools.partial`. In this way it is also possible to pass keyword arguments. To pass a function with both positional and keyword arguments, set all arguments as keyword arguments, just leaving the *frame* argument unset::  def func(frame, art, *, y=None): ...  ani = FuncAnimation(fig, partial(func, art=ln, y='foo'))  If ``blit == True``, *func* must return an iterable of all artists that were modified or created. This information is used by the blitting algorithm to determine which parts of the figure have to be updated. The return value is unused if ``blit == False`` and may be omitted in that case.  frames : iterable, int, generator function, or None, optional Source of data to pass *func* and each frame of the animation  - If an iterable, then simply use the values provided. If the iterable has a length, it will override the *save_count* kwarg.  - If an integer, then equivalent to passing ``range(frames)``  - If a generator function, then must have the signature::  def gen_function() -> obj  - If *None*, then equivalent to passing ``itertools.count``.  In all of these cases, the values in *frames* is simply passed through to the user-supplied *func* and thus can be of any type.  init_func : callable, optional A function used to draw a clear frame. If not given, the results of drawing from the first item in the frames sequence will be used. This function will be called once before the first frame.  The required signature is::  def init_func() -> iterable_of_artists  If ``blit == True``, *init_func* must return an iterable of artists to be re-drawn. This information is used by the blitting algorithm to determine which parts of the figure have to be updated. The return value is unused if ``blit == False`` and may be omitted in that case.  fargs : tuple or None, optional Additional arguments to pass to each call to *func*. Note: the use of `functools.partial` is preferred over *fargs*. See *func* for details.  save_count : int, optional Fallback for the number of values from *frames* to cache. This is only used if the number of frames cannot be inferred from *frames*, i.e. when it's an iterator without length or a generator.  interval : int, default: 200 Delay between frames in milliseconds.  repeat_delay : int, default: 0 The delay in milliseconds between consecutive animation runs, if *repeat* is True.  repeat : bool, default: True Whether the animation repeats when the sequence of frames is completed.  blit : bool, default: False Whether blitting is used to optimize drawing. Note: when using blitting, any animated artists will be drawn according to their zorder; however, they will be drawn on top of any previous artists, regardless of their zorder.  cache_frame_data : bool, default: True Whether frame data is cached. Disabling cache might be helpful when frames contain large objects.
Params:
fig – The figure object used to get needed events, such as draw or resize.
func – The function to call at each frame. The first argument will be the next value in *frames*. Any additional positional arguments can be supplied using `functools.partial` or via the *fargs* parameter. The required signature is:: def func(frame, *fargs) -> iterable_of_artists It is often more convenient to provide the arguments using `functools.partial`. In this way it is also possible to pass keyword arguments. To pass a function with both positional and keyword arguments, set all arguments as keyword arguments, just leaving the *frame* argument unset:: def func(frame, art, *, y=None): ... ani = FuncAnimation(fig, partial(func, art=ln, y='foo')) If ``blit == True``, *func* must return an iterable of all artists that were modified or created. This information is used by the blitting algorithm to determine which parts of the figure have to be updated. The return value is unused if ``blit == False`` and may be omitted in that case.
frames – Source of data to pass *func* and each frame of the animation - If an iterable, then simply use the values provided. If the iterable has a length, it will override the *save_count* kwarg. - If an integer, then equivalent to passing ``range(frames)`` - If a generator function, then must have the signature:: def gen_function() -> obj - If *None*, then equivalent to passing ``itertools.count``. In all of these cases, the values in *frames* is simply passed through to the user-supplied *func* and thus can be of any type.
init_func – A function used to draw a clear frame. If not given, the results of drawing from the first item in the frames sequence will be used. This function will be called once before the first frame. The required signature is:: def init_func() -> iterable_of_artists If ``blit == True``, *init_func* must return an iterable of artists to be re-drawn. This information is used by the blitting algorithm to determine which parts of the figure have to be updated. The return value is unused if ``blit == False`` and may be omitted in that case.
fargs – Additional arguments to pass to each call to *func*. Note: the use of `functools.partial` is preferred over *fargs*. See *func* for details.
save_count – Fallback for the number of values from *frames* to cache. This is only used if the number of frames cannot be inferred from *frames*, i.e. when it's an iterator without length or a generator.
cache_frame_data – Whether frame data is cached. Disabling cache might be helpful when frames contain large objects.
  • fig:图形对象(Figure),用于获取绘制、调整大小等事件。这是动画的画布。
  • func:可调用对象(函数),每帧调用的函数。该函数的第一个参数将是 frames 中的下一个值。任何其他的位置参数可以通过 fargs 参数提供。如果 blit 为 True,则该函数必须返回一个被修改或创建的所有图形元素(artists)的可迭代对象。
  • frames:可迭代对象、整数、生成器函数或 None,可选。用于传递给 func 和动画的每一帧的数据源。如果是可迭代对象,则直接使用提供的值。如果是一个整数,则相当于传递 range(frames)。如果是一个生成器函数,则必须具有特定的签名。如果为 None,则相当于传递 itertools.count。
  • init_func:可调用对象(函数),可选。用于绘制清空画面的函数。如果未提供,则将使用 frames 序列中的第一个项目的绘图结果。此函数将在第一帧之前被调用一次。如果 blit 为 True,则 init_func 必须返回一个将被重新绘制的图形元素(artists)的可迭代对象。
  • fargs:元组或 None,可选。传递给每次调用 func 的附加参数。
  • save_count:整数,可选。要缓存的 frames 中的值的数量。
  • interval:数字,可选。帧之间的延迟时间(以毫秒为单位)。默认为 200。
  • blit:布尔值,可选。控制是否使用 blitting 来优化绘制。当使用 blitting 时,只有变化的图形元素会被重新绘制,从而提高性能。
  • cache_frame_data:布尔值,可选。控制是否缓存帧数据。默认为 True。

方法说明

  • save:将动画保存为电影文件。
  • to_html5_video:将动画转换为 HTML5 视频。
  • to_jshtml:生成动画的 HTML 表示形式。

(4)注意事项

  • 性能:对于复杂的动画,可能需要优化性能,比如通过减少每次更新的数据量(使用 blit=True 参数)或调整帧的更新间隔。
  • 兼容性:保存动画时,不同的文件格式(如GIF、MP4)可能需要不同的编解码器支持。确保你的环境中安装了必要的编解码器。
  • 交互性:动画在Jupyter Notebook等交互式环境中可能表现不同,需要根据具体环境调整显示方式。

1.2、修改 matplotlib 背景

在上述示例代码的情况下,我们引入一些修改颜色的配置,

import numpy as np
import matplotlib.pyplot as plt
from matplotlib.animation import FuncAnimation# 准备数据
x = np.linspace(0, 2 * np.pi, 100)
y = np.sin(x)# 创建图形和轴
fig, ax = plt.subplots()
line, = ax.plot([], [], 'r-')  # 初始化一个空线条对象
ax.set_xlim(0, 2 * np.pi)  # 设置X轴范围
ax.set_ylim(-1.5, 1.5)  # 设置Y轴范围# 修改轴背景颜色
ax.set_facecolor("orange")  
# OR
# ax.set(facecolor = "orange")# 修改绘图背景颜色
fig.patch.set_facecolor('yellow')   
fig.patch.set_alpha(1.0)# 移除图表的上边框和右边框
ax.spines['right'].set_visible(False)
ax.spines['top'].set_visible(False)# 设置虚线网格线
ax.set_axisbelow(True)
ax.yaxis.grid(color='gray', linestyle='dashed', alpha=0.7)# 定义更新函数
def update(frame):line.set_data(x[:frame], y[:frame])  # 更新线条数据return line,# 创建 FuncAnimation 对象
ani = FuncAnimation(fig, update, frames=len(x), interval=50, blit=True)# ani.save("animation.gif", writer="imagemagick", fps=30)# 显示动画
plt.show()

修改前

在这里插入图片描述

修改后
在这里插入图片描述
换个背景图试试

import numpy as np
import matplotlib.pyplot as plt
from matplotlib.animation import FuncAnimation# 准备数据
x = np.linspace(0, 20 * np.pi, 100)
y = 9* np.sin(x)# 创建图形和轴
fig, ax = plt.subplots()
line, = ax.plot([], [], 'r-')  # 初始化一个空线条对象img = plt.imread("123.jpg")
ax.imshow(img, extent=[0, 65, -10, 10])  # 横纵坐标范围# 定义更新函数
def update(frame):line.set_data(x[:frame], y[:frame])  # 更新线条数据return line,# 创建 FuncAnimation 对象
ani = FuncAnimation(fig, update, frames=len(x), interval=50, blit=True)ani.save("animation.gif", writer="imagemagick", fps=30)# 显示动画
plt.show()

原始图片

在这里插入图片描述

添加之后的效果
在这里插入图片描述

2、matplotlib + imageio

2.1、折线图

先画个简单的折线图

import os
import numpy as np
import matplotlib.pyplot as plt
import imageionp.random.seed(1234)# 生成40个取值在30-40的数
y = np.random.randint(30, 40, size=(40))
print(y)
"""
[33 36 35 34 38 39 31 37 39 36 38 30 35 30 39 36 32 30 35 32 36 33 37 3039 30 33 32 33 31 33 31 33 37 31 37 34 30 35 31]
"""
# 绘制折线
plt.plot(y)
# 设置y轴最小值和最大值
plt.ylim(20, 50)# 显示
plt.show()

在这里插入图片描述

保存最后几个点的数据,然后绘制成 gif

import os
import numpy as np
import matplotlib.pyplot as plt
import imageionp.random.seed(1234)# 生成40个取值在30-40的数
y = np.random.randint(30, 40, size=(40))
print(y)
"""
[33 36 35 34 38 39 31 37 39 36 38 30 35 30 39 36 32 30 35 32 36 33 37 3039 30 33 32 33 31 33 31 33 37 31 37 34 30 35 31]
"""
# 绘制折线
plt.plot(y)
# 设置y轴最小值和最大值
plt.ylim(20, 50)# 显示
plt.show()# 第一张图
plt.plot(y[:-3])
plt.ylim(20, 50)
plt.savefig('1.png')
plt.show()# 第二张图
plt.plot(y[:-2])
plt.ylim(20, 50)
plt.savefig('2.png')
plt.show()# 第三张图
plt.plot(y[:-1])
plt.ylim(20, 50)
plt.savefig('3.png')
plt.show()# 第四张图
plt.plot(y)
plt.ylim(20, 50)
plt.savefig('4.png')
plt.show()# 生成Gif
with imageio.get_writer('mygif.gif', mode='I') as writer:for filename in ['1.png', '2.png', '3.png', '4.png']:image = imageio.imread(filename)writer.append_data(image)

横坐标 0 至 36
在这里插入图片描述

横坐标 0 至 37

在这里插入图片描述

横坐标 0 至 38

在这里插入图片描述

横坐标 0 至 39

在这里插入图片描述

合并成为 gif(仅播放一次)

请添加图片描述

下面把所有点都保存下来,绘制动态图(仅播放一次)

import os
import numpy as np
import matplotlib.pyplot as plt
import imageionp.random.seed(1234)# 生成40个取值在30-40的数
y = np.random.randint(30, 40, size=(40))
print(y)
"""
[33 36 35 34 38 39 31 37 39 36 38 30 35 30 39 36 32 30 35 32 36 33 37 3039 30 33 32 33 31 33 31 33 37 31 37 34 30 35 31]
"""
# 绘制折线
plt.plot(y)
# 设置y轴最小值和最大值
plt.ylim(20, 50)# 显示
plt.show()filenames = []
num = 0
for i in y:num += 1# 绘制40张折线图plt.plot(y[:num])plt.ylim(20, 50)# 保存图片文件filename = f'{num}.png'filenames.append(filename)plt.savefig(filename)plt.close()# 生成gif
with imageio.get_writer('mygif.gif', mode='I') as writer:for filename in filenames:image = imageio.imread(filename)writer.append_data(image)# 删除40张折线图
for filename in set(filenames):os.remove(filename)

在这里插入图片描述

2.2、条形图

import os
import numpy as np
import matplotlib.pyplot as plt
import imageionp.random.seed(1234)x = [1, 2, 3, 4, 5]
coordinates_lists = [[0, 0, 0, 0, 0],[10, 30, 60, 30, 10],[70, 40, 20, 40, 70],[10, 20, 30, 40, 50],[50, 40, 30, 20, 10],[75, 0, 75, 0, 75],[0, 0, 0, 0, 0]]
filenames = []
for index, y in enumerate(coordinates_lists):# 条形图plt.bar(x, y)plt.ylim(0, 80)# 保存图片文件filename = f'{index}.png'filenames.append(filename)# 重复最后一张图形15帧(数值都为0),15张图片if (index == len(coordinates_lists) - 1):for i in range(15):filenames.append(filename)# 保存plt.savefig(filename)plt.close()# 生成gif
with imageio.get_writer('mygif.gif', mode='I') as writer:for filename in filenames:image = imageio.imread(filename)writer.append_data(image)# 删除20张柱状图
for filename in set(filenames):os.remove(filename)

生成的图片

在这里插入图片描述

生成的 gif(播放一次)

在这里插入图片描述

看起来太快了,优化代码使其平滑

import os
import numpy as np
import matplotlib.pyplot as plt
import imageionp.random.seed(1234)n_frames = 10  # 怕内存不够的话可以设置小一些
x = [1, 2, 3, 4, 5]
coordinates_lists = [[0, 0, 0, 0, 0],[10, 30, 60, 30, 10],[70, 40, 20, 40, 70],[10, 20, 30, 40, 50],[50, 40, 30, 20, 10],[75, 0, 75, 0, 75],[0, 0, 0, 0, 0]]
print('生成图表\n')
filenames = []
for index in np.arange(0, len(coordinates_lists) - 1):# 获取当前图像及下一图像的y轴坐标值y = coordinates_lists[index]y1 = coordinates_lists[index + 1]# 计算当前图像与下一图像y轴坐标差值y_path = np.array(y1) - np.array(y)for i in np.arange(0, n_frames + 1):# 分配每帧的y轴移动距离# 逐帧增加y轴的坐标值y_temp = (y + (y_path / n_frames) * i)# 绘制条形图plt.bar(x, y_temp)plt.ylim(0, 80)# 保存每一帧的图像filename = f'frame_{index}_{i}.png'filenames.append(filename)# 最后一帧重复,画面停留一会if (i == n_frames):for i in range(5):filenames.append(filename)# 保存图片plt.savefig(filename)plt.close()
print('保存图表\n')# 生成GIF
print('生成GIF\n')
with imageio.get_writer('mybars.gif', mode='I') as writer:for filename in filenames:image = imageio.imread(filename)writer.append_data(image)
print('保存GIF\n')print('删除图片\n')
# 删除图片
for filename in set(filenames):os.remove(filename)
print('完成')

原理解释统计柱状图当前帧和下一帧的差值,然后插帧平滑过去,这里插帧数量配置为了 n_frames = 10

最终生成的 gif 如下(仅播放一次),可以观察到平滑了很多
在这里插入图片描述

接下来美化下界面

import os
import numpy as np
import matplotlib.pyplot as plt
import imageionp.random.seed(1234)n_frames = 5
bg_color = '#95A4AD'
bar_color = '#283F4E'
gif_name = 'bars'
x = [1, 2, 3, 4, 5]
coordinates_lists = [[0, 0, 0, 0, 0],[10, 30, 60, 30, 10],[70, 40, 20, 40, 70],[10, 20, 30, 40, 50],[50, 40, 30, 20, 10],[75, 0, 75, 0, 75],[0, 0, 0, 0, 0]]
print('生成图表\n')
filenames = []
for index in np.arange(0, len(coordinates_lists) - 1):y = coordinates_lists[index]y1 = coordinates_lists[index + 1]y_path = np.array(y1) - np.array(y)for i in np.arange(0, n_frames + 1):y_temp = (y + (y_path / n_frames) * i)# 绘制条形图fig, ax = plt.subplots(figsize=(8, 4))ax.set_facecolor(bg_color)plt.bar(x, y_temp, width=0.4, color=bar_color)plt.ylim(0, 80)# 移除图表的上边框和右边框ax.spines['right'].set_visible(False)ax.spines['top'].set_visible(False)# 设置虚线网格线ax.set_axisbelow(True)ax.yaxis.grid(color='gray', linestyle='dashed', alpha=0.7)# 保存每一帧的图像filename = f'images/frame_{index}_{i}.png'filenames.append(filename)# 最后一帧重复,画面停留一会if (i == n_frames):for i in range(5):filenames.append(filename)# 保存图片plt.savefig(filename, dpi=96, facecolor=bg_color)plt.close()
print('保存图表\n')# 生成GIF
print('生成GIF\n')
with imageio.get_writer(f'{gif_name}.gif', mode='I') as writer:for filename in filenames:image = imageio.imread(filename)writer.append_data(image)
print('保存GIF\n')print('删除图片\n')
# 删除图片
for filename in set(filenames):os.remove(filename)
print('完成')

看看生成的 gif 效果(仅播放一次)

在这里插入图片描述
给图表添加了背景色、条形图上色、去除边框、增加网格线等。

2.3、散点图

import os
import numpy as np
import matplotlib.pyplot as plt
import imageionp.random.seed(1234)coordinates_lists = [[[0], [0]],[[100, 200, 300], [100, 200, 300]],[[400, 500, 600], [400, 500, 600]],[[400, 500, 600, 400, 500, 600], [400, 500, 600, 600, 500, 400]],[[500], [500]],[[0], [0]]]
gif_name = 'movie'
n_frames = 5
bg_color = '#95A4AD'
marker_color = '#283F4E'
marker_size = 25print('生成图表\n')
filenames = []
for index in np.arange(0, len(coordinates_lists) - 1):# 获取当前图像及下一图像的x与y轴坐标值x = coordinates_lists[index][0]  # 当前帧y = coordinates_lists[index][1]x1 = coordinates_lists[index + 1][0]  # 下一帧y1 = coordinates_lists[index + 1][1]# 查看两点差值while len(x) < len(x1):diff = len(x1) - len(x)x = x + x[:diff]y = y + y[:diff]while len(x1) < len(x):diff = len(x) - len(x1)x1 = x1 + x1[:diff]y1 = y1 + y1[:diff]# 计算路径x_path = np.array(x1) - np.array(x)y_path = np.array(y1) - np.array(y)for i in np.arange(0, n_frames + 1):# 计算当前位置x_temp = (x + (x_path / n_frames) * i)y_temp = (y + (y_path / n_frames) * i)# 绘制图表fig, ax = plt.subplots(figsize=(6, 6), subplot_kw=dict(aspect="equal"))ax.set_facecolor(bg_color)plt.scatter(x_temp, y_temp, c=marker_color, s=marker_size)plt.xlim(0, 1000)plt.ylim(0, 1000)# 移除边框线ax.spines['right'].set_visible(False)ax.spines['top'].set_visible(False)# 网格线ax.set_axisbelow(True)ax.yaxis.grid(color='gray', linestyle='dashed', alpha=0.7)ax.xaxis.grid(color='gray', linestyle='dashed', alpha=0.7)# 保存图片filename = f'images/frame_{index}_{i}.png'filenames.append(filename)if (i == n_frames):for i in range(5):filenames.append(filename)# 保存plt.savefig(filename, dpi=96, facecolor=bg_color)plt.close()
print('保存图表\n')# 生成GIF
print('生成GIF\n')
with imageio.get_writer(f'{gif_name}.gif', mode='I') as writer:for filename in filenames:image = imageio.imread(filename)writer.append_data(image)
print('保存GIF\n')print('删除图片\n')
# 删除图片
for filename in set(filenames):os.remove(filename)
print('完成')

思路,计算前后帧坐标点数量的差 diff ,然后 while 循环来复制以实现数量平衡 x = x + x[:diff],最后插帧平滑移动 x_temp = (x + (x_path / n_frames) * i)

在这里插入图片描述

3、参考

  • 太强了,用 Matplotlib+Imageio 制作动画!
  • 如何在 Matplotlib 中更改绘图背景

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.mzph.cn/news/895100.shtml

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈email:809451989@qq.com,一经查实,立即删除!

相关文章

【东莞常平】戴尔R710服务器不开机维修分享

1&#xff1a;2025-02-06一位老客户的朋友刚开工公司ERP服务器一台戴尔老服务器故障无法开机&#xff0c;于是经老客户介绍找到我们。 2&#xff1a;服务器型号是DELL PowerEdge R710 这个服务器至少也有15年以上的使用年限了。 3&#xff1a;客户反馈的故障问题为&#xff1a;…

Spring AI -使用Spring快速开发ChatGPT应用

前言 Spring在Java生态中一直占据大半江山。最近我发现Spring社区推出了一个Spring AI项目&#xff0c;目前该项目还属于Spring实验性项目&#xff0c;但是我们可以通过该项目&#xff0c;可以非常快速的开发出GPT对话应用。 本篇文章将会对SpringAI进行简单的介绍和使用&#…

经典排序算法复习----C语言

经典排序算法复习 分类 交换类 冒泡快排 分配类 计数排序基数排序 选择类 选择排序 堆排序 归并类 归并排序 插入类 直接插入排序 希尔排序 折半插入排序 冒泡排序 基于交换。每一轮找最大值放到数组尾部 //冒泡排序 void bubSort(int* arr,int size){bool sorte…

BFS解决拓扑排序(3题)

目录 拓扑排序 1.如何排序&#xff1f; 2.如何形成拓扑排序 3.如何建图 1.看数据稠密度 2. 根据算法流程灵活建图 1.课程表 2.课程表2 3.火星词典 拓扑排序 找到做事情的先后顺序&#xff0c;拓扑排序的结果可能不是唯一的 1.如何排序&#xff1f; 1.找出图中入度为…

kafka 3.5.0 raft协议安装

前言 最近做项目&#xff0c;需要使用kafka进行通信&#xff0c;且只能使用kafka&#xff0c;笔者没有测试集群&#xff0c;就自己搭建了kafka集群&#xff0c;实际上笔者在很早之前就搭建了&#xff0c;因为当时还是zookeeper&#xff08;简称ZK&#xff09;注册元数据&#…

Unity项目接入xLua的一种流程

1. 导入xlua 首先导入xlua&#xff0c;这个不用多说 2. 编写C#和Lua交互脚本 基础版本&#xff0c;即xlua自带的版本 using System.Collections; using System.Collections.Generic; using UnityEngine; using XLua; using System; using System.IO;[Serializable] public…

四次挥手详解

文章目录 一、四次挥手各状态FIN_WAIT_1CLOSE_WAITFIN_WAIT_2LAST_ACKTIME_WAITCLOSE 二、双方同时调用close()&#xff0c;FIN_WAIT_1状态后进入CLOSING状态CLOSING状态 三、TIME_WAIT状态详解(1) TIME_WAIT状态下的2MSL是什么MSL &#xff08;报文最大生存时间&#xff09;为…

【嵌入式 Linux 音视频+ AI 实战项目】瑞芯微 Rockchip 系列 RK3588-基于深度学习的人脸门禁+ IPC 智能安防监控系统

前言 本文主要介绍我最近开发的一个个人实战项目&#xff0c;“基于深度学习的人脸门禁 IPC 智能安防监控系统”&#xff0c;全程满帧流畅运行。这个项目我目前全网搜了一圈&#xff0c;还没发现有相关类型的开源项目。这个项目只要稍微改进下&#xff0c;就可以变成市面上目前…

java: framework from BLL、DAL、IDAL、MODEL、Factory using oracle

oracel 21c sql: -- 创建 School 表 CREATE TABLE School (SchoolId CHAR(5) NOT NULL,SchoolName NVARCHAR2(500) NOT NULL,SchoolTelNo VARCHAR2(8) NULL,PRIMARY KEY (SchoolId) );CREATE OR REPLACE PROCEDURE addschool(p_school_id IN CHAR,p_school_name IN NVARCHAR2,p…

1.攻防世界 baby_web

题目描述这里有提示&#xff0c;初始页面 进入题目页面如下 很简洁的页面只有一行HELLO WORLD ctrlu查看了源码也没有信息 用burp suite抓包&#xff0c;并发送到重放器 根据提示&#xff08;初始页面&#xff09;修改访问index.php文件 index.php index.php 是一种常见的…

什么是三层交换技术?与二层有什么区别?

什么是三层交换技术&#xff1f;让你的网络飞起来&#xff01; 一. 什么是三层交换技术&#xff1f;二. 工作原理三. 优点四. 应用场景五. 总结 前言 点个免费的赞和关注&#xff0c;有错误的地方请指出&#xff0c;看个人主页有惊喜。 作者&#xff1a;神的孩子都在歌唱 大家好…

【机器学习】数据预处理之数据归一化

数据预处理之数据归一化 一、摘要二、数据归一化概念三、数据归一化实现方法3.1 最值归一化方法3.2 均值方差归一化方法 一、摘要 本文主要讲述了数据归一化&#xff08;Feature Scaling&#xff09;的重要性及其方法。首先通过肿瘤大小和发现时间的例子&#xff0c;说明了不同…

【AIGC】语言模型的发展历程:从统计方法到大规模预训练模型的演化

博客主页&#xff1a; [小ᶻ☡꙳ᵃⁱᵍᶜ꙳] 本文专栏: AIGC | ChatGPT 文章目录 &#x1f4af;前言&#x1f4af;语言模型的发展历程&#xff1a;从统计方法到大规模预训练模型的演化1 统计语言模型&#xff08;Statistical Language Model, SLM&#xff09;&#xff1a;统…

Java面试题2025-JVM

JVM 1.为什么需要JVM&#xff0c;不要JVM可以吗&#xff1f; 1.JVM可以帮助我们屏蔽底层的操作系统 一次编译&#xff0c;到处运行 2.JVM可以运行Class文件 2.JDK&#xff0c;JRE以及JVM的关系 3.我们的编译器到底干了什么事&#xff1f; 仅仅是将我们的 .java 文件转换成了…

Deepseek的MLA技术原理介绍

DeepSeek的MLA(Multi-head Latent Attention)技术是一种创新的注意力机制,旨在优化Transformer模型的计算效率和内存使用,同时保持模型性能。以下是MLA技术的详细原理和特点: 1. 核心思想 MLA技术通过低秩联合压缩技术,将多个注意力头的键(Key)和值(Value)映射到一…

QML初识

目录 一、关于QML 二、布局定位和锚点 1.布局定位 2.锚点详解 三、数据绑定 1.基本概念 2.绑定方法 3.数据模型绑定 四、附加属性及信号 1.附加属性 2.信号 一、关于QML QML是Qt框架中的一种声明式编程语言&#xff0c;用于描述用户界面的外观和行为&#xff1b;Qu…

java项目之美妆产品进销存管理系统的设计与开发源码(ssm+mysql)

项目简介 美妆产品进销存管理系统的设计与开发实现了以下功能&#xff1a; 美妆产品进销存管理系统的设计与开发的主要使用者分为管理员登录后修改个人的密码。产品分类管理中&#xff0c;对公司内的所有产品分类进行录入&#xff0c;也可以对产品分类进行修改和删除。产品管…

Python(pymysql包)操作MySQL【增删改查】

下载pymysql&#xff1a; pip install pymysql 在MySQL中创建数据库&#xff1a;unicom create database unicom DEFAULT CHARSET utf8 COLLATE utf8_general_ci;use unicom; 在unicom中创建数据表&#xff1a;admin create table admin(id int not null primary key auto_i…

HTTP无状态的概念以及对后端服务的设计会产生的影响

HTTP无状态(Statelessness) 是指每个HTTP请求都是独立的,服务器不会记住或依赖于前一个请求的任何信息。每次请求的处理都与其他请求没有直接关系。也就是说,服务器在处理请求时,不会存储关于客户端状态的信息。 一、HTTP无状态的具体含义 ①每个请求独立:每个请求包含了…

操作系统—进程与线程

补充知识 PSW程序状态字寄存器PC程序计数器&#xff1a;存放下一条指令的地址IR指令寄存器&#xff1a;存放当前正在执行的指令通用寄存器&#xff1a;存放其他一些必要信息 进程 进程&#xff1a;进程是进程实体的运行过程&#xff0c;是系统进行资源分配和调度的一个独立单位…