标签: customization

Xamarin Android 使用 SetSound 作为通知通道在通知上播放自定义声音

我已经浪费了至少一天的时间来尝试完成这项工作。我正在尝试播放收到通知后放置在 Resources/raw 中的 mp3 文件。我不知道如何获取 Uri。我的问题是:

1.要播放自定义文件,您必须将其放置在 Resources/raw 中,还是也可以放置在 Xamarin Android 项目下的 Assets/Sounds 中。

2.如何根据mp3文件所在位置正确获取Uri。

这是我的代码:

private void createNotificationChannel()
        {
            var channelName = GetString(Resource.String.noti_chan_urgent);
            var channelDescription = GetString(Resource.String.noti_chan_urgent_description);

            // set the vibration patterm for the channel
            long[] vibrationPattern = { 100, 200, 300, 400, 500, 400, 300, 200, 400 };

            // Creating an Audio Attribute
            var alarmAttributes = new AudioAttributes.Builder().SetUsage(AudioUsageKind.Alarm).Build();

            // Create the uri for the alarm file
            var alarmUri = Android.Net.Uri.Parse("MyApp.Android/Resources/raw/alarm.mp3");   // this must be wrong because its not …
Run Code Online (Sandbox Code Playgroud)

customization push-notification xamarin.android

5
推荐指数
1
解决办法
2476
查看次数

如何在 matplotlib 中完全自定义的位置放置小刻度?

假设我想在自定义位置向 x 轴添加次要刻度,相当于此主要刻度的命令:plt.xticks([1,2,3])

我努力了:

import matplotlib.pyplot as plt
x = [1,2,3]
y = [1,4,9]
plt.scatter(x,y)
ax = plt.gca()
ax.xaxis.set_minor_locator([1.1, 1.9, 2.5])
Run Code Online (Sandbox Code Playgroud)

但这会引发错误,因为最后一个命令可能需要一个股票代码对象,而不是参数中的列表。有什么Pythonic的方法可以解决这个问题吗?

python customization plot matplotlib axis-labels

5
推荐指数
1
解决办法
3428
查看次数

clang-format 仅更改一个文件中的一种格式选项

我们的存储库的根文件夹中有一个自定义文件,并对所有C++ 文件.clang-format使用 clang-format 。-style=fileC

我喜欢只更改一个文件的 clang-format 格式规则。我特别喜欢将BinPackArguments形式切换truefalse.

我知道,我可以将.clang-format文件放在相应的文件夹中。该选项会影响该文件夹中的所有文件。

一次以不同的方式格式化它不是一个选项,因为我们的版本控制系统将拒绝未格式化的文件。

我知道,我可以通过评论关闭格式化程序

// clang-format off
Run Code Online (Sandbox Code Playgroud)

这样做的缺点是文件根本没有格式化。

有没有一种方法可以仅更改一个文件的一个选项(也许通过评论)?

c++ customization clang-format

5
推荐指数
0
解决办法
654
查看次数

如何将 y_true 作为字典传递给自定义损失函数而不改变?

我需要使用tf.keras.*. 但:

  • 空白类并不像 tf 期望的那样为零,但是(num_classes - 1)相反。
  • 输入图像的宽度事先未知(不同批次的宽度不同)。

我想利用tf.nn.ctc_loss其中有一些很好的论点:blank_index。所以我做了一个简单的包装器来计算 CTC 损失:

    class CTCLossWrapper(tf.keras.losses.Loss):
        def __init__(self, blank_class: int, reduction: str = tf.keras.losses.Reduction.AUTO, name: str = 'ctc_loss'):
            super().__init__(reduction=reduction, name=name)
            self.blank_class = blank_class
        
        def call(self, y_true, y_pred):
            output = y_true['output']
            targets, target_lenghts = output['targets'], output['target_lengths']
            y_pred = tf.math.log(tf.transpose(y_pred, perm=[1, 0, 2]) + K.epsilon())
            max_input_len = K.cast(K.shape(y_pred)[1], dtype='int32')
            input_lengths = tf.ones((K.shape(y_pred)[0]), dtype='int32') * max_input_len
            return tf.nn.ctc_loss(
                labels=targets,
                logits=y_pred,
                label_length=target_lenghts,
                logit_length=input_lengths,
                blank_index=self.blank_class
            )
Run Code Online (Sandbox Code Playgroud)

我还编写了一个简单的生成器函数,它生成训练样本:

def generator(dataset, batch_size: …
Run Code Online (Sandbox Code Playgroud)

python customization keras tensorflow loss-function

5
推荐指数
0
解决办法
999
查看次数

Plotly: Range slider not being displayed for row count > 500

在此输入图像描述

从图像中可以看出,范围滑块的脚手架已生成,但其内部的迹线并未生成。除此之外,它的功能也很齐全。通过一些实验,我发现只有当你设置 no 时才可以。行数为 500 或更少,它会正确显示。有没有办法显示更多行?这是重现的代码-

size = 501 #change this to change no. of rows

import numpy as np
import pandas as pd
import plotly.express as px

df = {'date': pd.date_range(start='2021-01-01', periods=size, freq='D'),
     'new_cases': np.random.random(size=size),
     'new_cases_smoothed': np.random.random(size=size)}

df = pd.DataFrame(df)
fig = px.line(df, x='date', y=['new_cases','new_cases_smoothed'])
fig.update_layout(xaxis=dict(rangeslider=dict(visible=True),type="date"))
fig.show()
Run Code Online (Sandbox Code Playgroud)

python customization data-visualization plotly plotly-python

5
推荐指数
2
解决办法
1848
查看次数

如何使用自定义数据集运行 Keras Retinanet 对象检测代码示例?

我正在尝试从源代码实现 Keras Retinanet 示例:

https://keras.io/examples/vision/retinanet/

我确实让示例与 COCO 数据集完美运行。现在我想使用我自己的自定义对象检测数据集运行该示例。在网上进行了几天的研究后,我仍然不太清楚,我需要如何编辑示例代码才能使用我自己的数据集(即一组 .jpg 图像 + 注释 .xml 文件,这些文件是用标签图像)。

我怀疑我需要熟悉tensorflow_dataset-library?我的猜测是,代码中的这部分是我应该为自己的数据集进行定制的地方:

https://keras.io/examples/vision/retinanet/#load-the-coco2017-dataset-using-tensorflow-datasets

有什么建议或好的参考值得研究,以使 Keras Retinanet 对象检测示例与我自己的数据集一起使用?

python customization object-detection keras retinanet

5
推荐指数
1
解决办法
2041
查看次数

如何从VS2022状态栏中删除“添加到源代码管理”按钮?

有没有办法去除在此输入图像描述VS 2022 状态栏中的按钮?我能找到的所有解决方案都是针对 VS 2022 之前的版本。

我不使用任何类型的源代码控制,并且该按钮在状态栏中停留在视觉上令人不愉快/烦人,尤其是当它位于有用的信息旁边时。

ide customization ide-customization visual-studio visual-studio-2022

5
推荐指数
1
解决办法
437
查看次数

在可通过下拉列表选择的特定文件/文件夹上运行 VS Code 任务

我试图弄清楚如何在可通过下拉列表选择的特定文件夹/文件上运行 VS Code 任务。

例子:

  1. 打开命令面板(Ctrl+Shift+P)
  2. 过滤“任务”-> 选择“任务:运行任务”
  3. 选择要运行的任务,例如 Cpplint
  4. 新部分:现在不应立即执行它,而是应该打开一个下拉列表来选择要运行任务的文件夹/文件,或者您可以选择“全部”,它会像以前一样工作并运行任务在所有文件夹上,从根(此处:src)文件夹开始。

结构:

ws
|   
+-- .env
|   |  
|   +-- ...
|    
+-- src
    |  
    +-- dir1
    |   |
    |   +-- file 1.1
    |   +-- ... 
    |   +-- file 1.n
    +-- dir2
    |   |
    |   +-- file 2.1
    |   +-- ... 
    |   +-- file 2.n 
    |   +-- dir2.2
    |       |
    |       +-- file 2.2.1
    |       +-- ...
    |       +-- file 2.2.n 
    +-- ...
    |
    +-- dirn
        |
        +-- file n.1 …
Run Code Online (Sandbox Code Playgroud)

customization task visual-studio-code

5
推荐指数
1
解决办法
3740
查看次数

当有多个捕获时,如何对 nvim treesitter 进行语法高亮?

I am using NVIM v0.8.0-1210-gd367ed9b2 and I am trying to perform syntax highlighting for haskell in using treesitter. I would like the identifier for a function and its identifier for a function in a type definition to be highlighted differently, similar to how it is in VSCode. Currently, they are both highlighted as a function. If I perform :TSHighlightCaptureUnderCursor over the identifer for a function type definition, it says it is a capture of @variable, @function, @type. …

customization haskell syntax-highlighting neovim treesitter

5
推荐指数
0
解决办法
799
查看次数

自定义 state_dict() 和 load_state_dict() pytorch

我有一组嵌套的类(每个类型都是torch.nn.module)。在保存嵌套类之一的权重之前,我需要进行一些预处理。是否可以重写该state_dict()函数,以便我可以在自定义实现中插入预处理?

示例代码:

Class A(torch.nn.module):
    def __init__(self):
        super().__init__()
        self.b1 = B1()
        self.b2 = B2()

Class B1(torch.nn.module):
    def __init__(self):
        super().__init__()
        self.var = torch.nn.Parameter(torch.Tensor((3, 5), dtype=float))

Class B2(torch.nn.module):
    def __init__(self):
        super().__init__()
        self.var = torch.nn.Parameter(torch.Tensor((3, 5), dtype=float))

    def state_dict():
        # I want to override the default state_dict like this, but this does not work. 
        # Is there a way to achieve this?
        bool_var = self.var.bool().cpu().numpy()
        state_dict1 = super.state_dict()
        state_dict1.update({'var': bool_var})
        return state_dict1

    def load_state_dict(state_dict):
        state_dict['var'] = state_dict['var'].float()
        super.load_state_dict(state_dict)
        return
Run Code Online (Sandbox Code Playgroud)

具体来说,对于其中一个类,我想在保存变量之前将其转换为,并在加载时 …

python customization save pytorch

5
推荐指数
1
解决办法
432
查看次数